\hypertarget{classEventLoop}{
\section{EventLoop Class Reference}
\label{classEventLoop}\index{EventLoop@{EventLoop}}
}


Event Loop.  




{\ttfamily \#include $<$eventloop.hh$>$}

Inheritance diagram for EventLoop:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classEventLoop}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classEventLoop_a33fa78d25c8dc23ece149c805e0f2d17}{
\hyperlink{classEventLoop_a33fa78d25c8dc23ece149c805e0f2d17}{EventLoop} ()}
\label{classEventLoop_a33fa78d25c8dc23ece149c805e0f2d17}

\begin{DoxyCompactList}\small\item\em Constructor. \item\end{DoxyCompactList}\item 
\hypertarget{classEventLoop_acd0f2fd1a93194d07d2c9fe0c855b6a8}{
virtual \hyperlink{classEventLoop_acd0f2fd1a93194d07d2c9fe0c855b6a8}{$\sim$EventLoop} ()}
\label{classEventLoop_acd0f2fd1a93194d07d2c9fe0c855b6a8}

\begin{DoxyCompactList}\small\item\em Destructor. \item\end{DoxyCompactList}\item 
void \hyperlink{classEventLoop_a6c3c78e283ef38929ccc3c199e321cfe}{run} ()
\begin{DoxyCompactList}\small\item\em Invoke all pending callbacks relating to \hyperlink{classXorpTimer}{XorpTimer} and file descriptor activity. \item\end{DoxyCompactList}\item 
\hypertarget{classEventLoop_aad4a2458548078a78f609041da338ad9}{
void {\bfseries set\_\-debug} (bool v)}
\label{classEventLoop_aad4a2458548078a78f609041da338ad9}

\item 
\hypertarget{classEventLoop_af4620937162cfe05d70348b91c8f930f}{
bool {\bfseries is\_\-debug} () const }
\label{classEventLoop_af4620937162cfe05d70348b91c8f930f}

\item 
\hyperlink{classTimerList}{TimerList} \& \hyperlink{classEventLoop_a9eea92ae27a8c95ad91158ffdbb7a40b}{timer\_\-list} ()
\item 
\hyperlink{classSelectorList}{SelectorList} \& \hyperlink{classEventLoop_a9760df4ca9212be2e9b37ce4618a838b}{selector\_\-list} ()
\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_ad61dae3346d546bcf501f6a612d65fa8}{new\_\-oneoff\_\-at} (const \hyperlink{classTimeVal}{TimeVal} \&when, const OneoffTimerCallback \&ocb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_af1bfcb0debfbf68859016de7b50d65af}{new\_\-oneoff\_\-after} (const \hyperlink{classTimeVal}{TimeVal} \&wait, const OneoffTimerCallback \&ocb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a6bd62bf9a3ab3992f68b250eb70b8216}{new\_\-oneoff\_\-after\_\-ms} (int ms, const OneoffTimerCallback \&ocb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
void \hyperlink{classEventLoop_a13e61a49e45798195992409aee0f25f6}{remove\_\-timer} (\hyperlink{classXorpTimer}{XorpTimer} \&t)
\begin{DoxyCompactList}\small\item\em Remove timer from timer list. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a0000279f1dca355a0b5e2dc8c9730b1f}{new\_\-periodic} (const \hyperlink{classTimeVal}{TimeVal} \&wait, const PeriodicTimerCallback \&pcb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add periodic timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a8ed88810a7e5feb1b8c09af2ebb2d2c1}{new\_\-periodic\_\-ms} (int ms, const PeriodicTimerCallback \&pcb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add periodic timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_afceb9b445c1e1547298cd8f3892b09f4}{set\_\-flag\_\-at} (const \hyperlink{classTimeVal}{TimeVal} \&when, bool $\ast$flag\_\-ptr, bool to\_\-value=true)
\begin{DoxyCompactList}\small\item\em Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a6af50845596fad9887990f775a5d5878}{set\_\-flag\_\-after} (const \hyperlink{classTimeVal}{TimeVal} \&wait, bool $\ast$flag\_\-ptr, bool to\_\-value=true)
\begin{DoxyCompactList}\small\item\em Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a7bbbfe464f416e07cb5ed2c342940ad1}{set\_\-flag\_\-after\_\-ms} (int ms, bool $\ast$flag\_\-ptr, bool to\_\-value=true)
\begin{DoxyCompactList}\small\item\em Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTimer}{XorpTimer} \hyperlink{classEventLoop_a8d423461a642dcc8ee3b9ffc8ba8b352}{new\_\-timer} (const BasicTimerCallback \&cb)
\begin{DoxyCompactList}\small\item\em Create a custom timer associated with \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTask}{XorpTask} \hyperlink{classEventLoop_a628231aebf09f71a48a559063ceb6275}{new\_\-oneoff\_\-task} (const OneoffTaskCallback \&cb, int priority=XorpTask::PRIORITY\_\-DEFAULT, int weight=XorpTask::WEIGHT\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Create a new one-\/time task to be scheduled with \hyperlink{protocolthe-p}{the} timers and file handlers. \item\end{DoxyCompactList}\item 
\hyperlink{classXorpTask}{XorpTask} \hyperlink{classEventLoop_a818fc8ecac2d6684f575ad41b851e4c9}{new\_\-task} (const RepeatedTaskCallback \&cb, int priority=XorpTask::PRIORITY\_\-DEFAULT, int weight=XorpTask::WEIGHT\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Create a new repeated task to be scheduled with \hyperlink{protocolthe-p}{the} timers and file handlers. \item\end{DoxyCompactList}\item 
bool \hyperlink{classEventLoop_ab018fd2c93f7e9ce451d2815a8476083}{add\_\-ioevent\_\-cb} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type, const IoEventCb \&cb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add a file descriptor and callback to be invoked when descriptor is ready for input or output. \item\end{DoxyCompactList}\item 
bool \hyperlink{classEventLoop_a57b5d8f3fde37cd80944359efa5f2be0}{remove\_\-ioevent\_\-cb} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type=IOT\_\-ANY)
\begin{DoxyCompactList}\small\item\em Remove callbacks associated with file descriptor. \item\end{DoxyCompactList}\item 
bool \hyperlink{classEventLoop_a9a7feb3e4c4707bfb71132ad080ca790}{timers\_\-pending} () const 
\item 
bool \hyperlink{classEventLoop_ae818b87482aa87ca8e5b5d82603298e2}{events\_\-pending} () const 
\item 
size\_\-t \hyperlink{classEventLoop_a18fbbc043297869768a25612da88ca6f}{timer\_\-list\_\-length} () const 
\item 
\hypertarget{classEventLoop_a52475b54376f8e142cc0cb50d39185c7}{
void \hyperlink{classEventLoop_a52475b54376f8e142cc0cb50d39185c7}{current\_\-time} (\hyperlink{classTimeVal}{TimeVal} \&now) const }
\label{classEventLoop_a52475b54376f8e142cc0cb50d39185c7}

\begin{DoxyCompactList}\small\item\em Get current time according to EventLoop's \hyperlink{classTimerList}{TimerList}. \item\end{DoxyCompactList}\item 
size\_\-t \hyperlink{classEventLoop_acc537bd13d100f8daa0c990c44f5fdbe}{descriptor\_\-count} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} count of \hyperlink{protocolthe-p}{the} descriptors that have been added. \item\end{DoxyCompactList}\item 
\hypertarget{classEventLoop_a85d9f7092a760c169564ae0ebed42715}{
void {\bfseries set\_\-aggressiveness} (int num)}
\label{classEventLoop_a85d9f7092a760c169564ae0ebed42715}

\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classEventLoop_a10bb8866e144f107661ea9c3c0390e46}{
void {\bfseries do\_\-work} ()}
\label{classEventLoop_a10bb8866e144f107661ea9c3c0390e46}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classEventLoop_aee5aaab36f28afb874397ed1db6e7ea9}{
\hyperlink{classClockBase}{ClockBase} $\ast$ {\bfseries \_\-clock}}
\label{classEventLoop_aee5aaab36f28afb874397ed1db6e7ea9}

\item 
\hypertarget{classEventLoop_a8569536aff8e1d5d2cb5e4d840ad6a94}{
\hyperlink{classTimerList}{TimerList} {\bfseries \_\-timer\_\-list}}
\label{classEventLoop_a8569536aff8e1d5d2cb5e4d840ad6a94}

\item 
\hypertarget{classEventLoop_aa2c624cfed3bebf36cf8cce0fe1c9c82}{
\hyperlink{classTaskList}{TaskList} {\bfseries \_\-task\_\-list}}
\label{classEventLoop_aa2c624cfed3bebf36cf8cce0fe1c9c82}

\item 
\hypertarget{classEventLoop_af317630b1beebb1ae20b04351f16d2b4}{
int {\bfseries \_\-aggressiveness}}
\label{classEventLoop_af317630b1beebb1ae20b04351f16d2b4}

\item 
\hypertarget{classEventLoop_ae904decce1deddec759fb5d0acedba1b}{
time\_\-t {\bfseries \_\-last\_\-ev\_\-run}}
\label{classEventLoop_ae904decce1deddec759fb5d0acedba1b}

\item 
\hypertarget{classEventLoop_aec2e7b8da40390efcd062d63bbf9a72f}{
time\_\-t {\bfseries \_\-last\_\-warned}}
\label{classEventLoop_aec2e7b8da40390efcd062d63bbf9a72f}

\item 
\hypertarget{classEventLoop_af60b0d11e88e7aff3d11a0ac8506e77a}{
bool {\bfseries \_\-is\_\-debug}}
\label{classEventLoop_af60b0d11e88e7aff3d11a0ac8506e77a}

\item 
\hypertarget{classEventLoop_a7649eb64af57645dea824762dd1b5328}{
bool {\bfseries \_\-last\_\-ev\_\-type} \mbox{[}XorpTask::PRIORITY\_\-INFINITY\mbox{]}}
\label{classEventLoop_a7649eb64af57645dea824762dd1b5328}

\item 
\hypertarget{classEventLoop_a23c513372e856001ac03c6031eab4ec2}{
\hyperlink{classSelectorList}{SelectorList} {\bfseries \_\-selector\_\-list}}
\label{classEventLoop_a23c513372e856001ac03c6031eab4ec2}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Event Loop. Co-\/ordinates interactions between a \hyperlink{classTimerList}{TimerList} and a \hyperlink{classSelectorList}{SelectorList} for Xorp processes. All \hyperlink{classXorpTimer}{XorpTimer} and select operations should be co-\/ordinated through this interface. 

\subsection{Member Function Documentation}
\hypertarget{classEventLoop_ab018fd2c93f7e9ce451d2815a8476083}{
\index{EventLoop@{EventLoop}!add\_\-ioevent\_\-cb@{add\_\-ioevent\_\-cb}}
\index{add\_\-ioevent\_\-cb@{add\_\-ioevent\_\-cb}!EventLoop@{EventLoop}}
\subsubsection[{add\_\-ioevent\_\-cb}]{\setlength{\rightskip}{0pt plus 5cm}bool EventLoop::add\_\-ioevent\_\-cb (
\begin{DoxyParamCaption}
\item[{{\bf XorpFd}}]{fd, }
\item[{IoEventType}]{type, }
\item[{const IoEventCb \&}]{cb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_ab018fd2c93f7e9ce451d2815a8476083}


Add a file descriptor and callback to be invoked when descriptor is ready for input or output. 

An IoEventType determines what type of I/O event will cause \hyperlink{protocolthe-p}{the} callback to be invoked.

Only one callback may be associated with each event type, e.g. one callback for read pending, one callback for write pending.

If multiple event types in are associated with \hyperlink{protocolthe-p}{the} same callback, \hyperlink{protocolthe-p}{the} callback is only invoked once, but \hyperlink{protocolthe-p}{the} mask argument passed to \hyperlink{protocolthe-p}{the} callback shows multiple event types.


\begin{DoxyParams}{Parameters}
{\em fd} & \hyperlink{protocolthe-p}{the} file descriptor. \\
\hline
{\em type} & \hyperlink{protocolthe-p}{the} IoEventType of \hyperlink{protocolthe-p}{the} event. \\
\hline
{\em cb} & object to be invoked when file descriptor has I/O pending. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if any error occurred. 
\end{DoxyReturn}
\hypertarget{classEventLoop_acc537bd13d100f8daa0c990c44f5fdbe}{
\index{EventLoop@{EventLoop}!descriptor\_\-count@{descriptor\_\-count}}
\index{descriptor\_\-count@{descriptor\_\-count}!EventLoop@{EventLoop}}
\subsubsection[{descriptor\_\-count}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t EventLoop::descriptor\_\-count (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}
\label{classEventLoop_acc537bd13d100f8daa0c990c44f5fdbe}


Get \hyperlink{protocolthe-p}{the} count of \hyperlink{protocolthe-p}{the} descriptors that have been added. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} count of \hyperlink{protocolthe-p}{the} descriptors that have been added. 
\end{DoxyReturn}
\hypertarget{classEventLoop_ae818b87482aa87ca8e5b5d82603298e2}{
\index{EventLoop@{EventLoop}!events\_\-pending@{events\_\-pending}}
\index{events\_\-pending@{events\_\-pending}!EventLoop@{EventLoop}}
\subsubsection[{events\_\-pending}]{\setlength{\rightskip}{0pt plus 5cm}bool EventLoop::events\_\-pending (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_ae818b87482aa87ca8e5b5d82603298e2}
\begin{DoxyReturn}{Returns}
true if any XorpTimers are present on EventLoop's \hyperlink{classTimerList}{TimerList} or any XorpTasks are present on \hyperlink{protocolthe-p}{the} \hyperlink{classTaskList}{TaskList}. 
\end{DoxyReturn}
\hypertarget{classEventLoop_af1bfcb0debfbf68859016de7b50d65af}{
\index{EventLoop@{EventLoop}!new\_\-oneoff\_\-after@{new\_\-oneoff\_\-after}}
\index{new\_\-oneoff\_\-after@{new\_\-oneoff\_\-after}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-oneoff\_\-after}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-oneoff\_\-after (
\begin{DoxyParamCaption}
\item[{const {\bf TimeVal} \&}]{wait, }
\item[{const OneoffTimerCallback \&}]{ocb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_af1bfcb0debfbf68859016de7b50d65af}


Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em wait} & \hyperlink{protocolthe-p}{the} relative time when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em ocb} & callback object that is invoked when timer expires. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a6bd62bf9a3ab3992f68b250eb70b8216}{
\index{EventLoop@{EventLoop}!new\_\-oneoff\_\-after\_\-ms@{new\_\-oneoff\_\-after\_\-ms}}
\index{new\_\-oneoff\_\-after\_\-ms@{new\_\-oneoff\_\-after\_\-ms}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-oneoff\_\-after\_\-ms}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-oneoff\_\-after\_\-ms (
\begin{DoxyParamCaption}
\item[{int}]{ms, }
\item[{const OneoffTimerCallback \&}]{ocb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a6bd62bf9a3ab3992f68b250eb70b8216}


Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em ms} & \hyperlink{protocolthe-p}{the} relative time in milliseconds when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em ocb} & callback object that is invoked when timer expires. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_ad61dae3346d546bcf501f6a612d65fa8}{
\index{EventLoop@{EventLoop}!new\_\-oneoff\_\-at@{new\_\-oneoff\_\-at}}
\index{new\_\-oneoff\_\-at@{new\_\-oneoff\_\-at}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-oneoff\_\-at}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-oneoff\_\-at (
\begin{DoxyParamCaption}
\item[{const {\bf TimeVal} \&}]{when, }
\item[{const OneoffTimerCallback \&}]{ocb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_ad61dae3346d546bcf501f6a612d65fa8}


Add a new one-\/off timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em when} & \hyperlink{protocolthe-p}{the} absolute time when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em ocb} & callback object that is invoked when timer expires. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a628231aebf09f71a48a559063ceb6275}{
\index{EventLoop@{EventLoop}!new\_\-oneoff\_\-task@{new\_\-oneoff\_\-task}}
\index{new\_\-oneoff\_\-task@{new\_\-oneoff\_\-task}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-oneoff\_\-task}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTask} EventLoop::new\_\-oneoff\_\-task (
\begin{DoxyParamCaption}
\item[{const OneoffTaskCallback \&}]{cb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}, }
\item[{int}]{weight = {\ttfamily XorpTask::WEIGHT\_\-DEFAULT}}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_a628231aebf09f71a48a559063ceb6275}


Create a new one-\/time task to be scheduled with \hyperlink{protocolthe-p}{the} timers and file handlers. 


\begin{DoxyParams}{Parameters}
{\em cb} & callback object that is invoked when task is run. \\
\hline
{\em priority} & \hyperlink{protocolthe-p}{the} scheduling priority for \hyperlink{protocolthe-p}{the} task. \\
\hline
{\em scheduler\_\-class} & \hyperlink{protocolthe-p}{the} scheduling class within \hyperlink{protocolthe-p}{the} priority level. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTask}{XorpTask} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a0000279f1dca355a0b5e2dc8c9730b1f}{
\index{EventLoop@{EventLoop}!new\_\-periodic@{new\_\-periodic}}
\index{new\_\-periodic@{new\_\-periodic}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-periodic}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-periodic (
\begin{DoxyParamCaption}
\item[{const {\bf TimeVal} \&}]{wait, }
\item[{const PeriodicTimerCallback \&}]{pcb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a0000279f1dca355a0b5e2dc8c9730b1f}


Add periodic timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em wait} & \hyperlink{protocolthe-p}{the} period when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em pcb} & user callback object that is invoked when timer expires. If \hyperlink{protocolthe-p}{the} callback returns false \hyperlink{protocolthe-p}{the} periodic \hyperlink{classXorpTimer}{XorpTimer} is unscheduled. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a8ed88810a7e5feb1b8c09af2ebb2d2c1}{
\index{EventLoop@{EventLoop}!new\_\-periodic\_\-ms@{new\_\-periodic\_\-ms}}
\index{new\_\-periodic\_\-ms@{new\_\-periodic\_\-ms}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-periodic\_\-ms}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-periodic\_\-ms (
\begin{DoxyParamCaption}
\item[{int}]{ms, }
\item[{const PeriodicTimerCallback \&}]{pcb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a8ed88810a7e5feb1b8c09af2ebb2d2c1}


Add periodic timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em ms} & \hyperlink{protocolthe-p}{the} period in milliseconds when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em pcb} & user callback object that is invoked when timer expires. If \hyperlink{protocolthe-p}{the} callback returns false \hyperlink{protocolthe-p}{the} periodic \hyperlink{classXorpTimer}{XorpTimer} is unscheduled. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a818fc8ecac2d6684f575ad41b851e4c9}{
\index{EventLoop@{EventLoop}!new\_\-task@{new\_\-task}}
\index{new\_\-task@{new\_\-task}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-task}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTask} EventLoop::new\_\-task (
\begin{DoxyParamCaption}
\item[{const RepeatedTaskCallback \&}]{cb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}, }
\item[{int}]{weight = {\ttfamily XorpTask::WEIGHT\_\-DEFAULT}}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_a818fc8ecac2d6684f575ad41b851e4c9}


Create a new repeated task to be scheduled with \hyperlink{protocolthe-p}{the} timers and file handlers. 


\begin{DoxyParams}{Parameters}
{\em cb} & callback object that is invoked when task is run. If \hyperlink{protocolthe-p}{the} callback returns true, \hyperlink{protocolthe-p}{the} task will continue to run, otherwise it will be unscheduled. \\
\hline
{\em priority} & \hyperlink{protocolthe-p}{the} scheduling priority for \hyperlink{protocolthe-p}{the} task. \\
\hline
{\em scheduler\_\-class} & \hyperlink{protocolthe-p}{the} scheduling class within \hyperlink{protocolthe-p}{the} priority level. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTask}{XorpTask} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a8d423461a642dcc8ee3b9ffc8ba8b352}{
\index{EventLoop@{EventLoop}!new\_\-timer@{new\_\-timer}}
\index{new\_\-timer@{new\_\-timer}!EventLoop@{EventLoop}}
\subsubsection[{new\_\-timer}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::new\_\-timer (
\begin{DoxyParamCaption}
\item[{const BasicTimerCallback \&}]{cb}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a8d423461a642dcc8ee3b9ffc8ba8b352}


Create a custom timer associated with \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 

The \hyperlink{classXorpTimer}{XorpTimer} object created needs to be explicitly scheduled with \hyperlink{protocolthe-p}{the} available \hyperlink{classXorpTimer}{XorpTimer} methods.


\begin{DoxyParams}{Parameters}
{\em cb} & user callback object that is invoked when timer expires. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a57b5d8f3fde37cd80944359efa5f2be0}{
\index{EventLoop@{EventLoop}!remove\_\-ioevent\_\-cb@{remove\_\-ioevent\_\-cb}}
\index{remove\_\-ioevent\_\-cb@{remove\_\-ioevent\_\-cb}!EventLoop@{EventLoop}}
\subsubsection[{remove\_\-ioevent\_\-cb}]{\setlength{\rightskip}{0pt plus 5cm}bool EventLoop::remove\_\-ioevent\_\-cb (
\begin{DoxyParamCaption}
\item[{{\bf XorpFd}}]{fd, }
\item[{IoEventType}]{type = {\ttfamily IOT\_\-ANY}}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_a57b5d8f3fde37cd80944359efa5f2be0}


Remove callbacks associated with file descriptor. 


\begin{DoxyParams}{Parameters}
{\em fd} & \hyperlink{protocolthe-p}{the} file descriptor. \\
\hline
{\em type} & \hyperlink{protocolthe-p}{the} event type to clear. The special value IOT\_\-ANY means clear any kind of callback. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if any error occurred. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a13e61a49e45798195992409aee0f25f6}{
\index{EventLoop@{EventLoop}!remove\_\-timer@{remove\_\-timer}}
\index{remove\_\-timer@{remove\_\-timer}!EventLoop@{EventLoop}}
\subsubsection[{remove\_\-timer}]{\setlength{\rightskip}{0pt plus 5cm}void EventLoop::remove\_\-timer (
\begin{DoxyParamCaption}
\item[{{\bf XorpTimer} \&}]{t}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_a13e61a49e45798195992409aee0f25f6}


Remove timer from timer list. 

\hypertarget{classEventLoop_a6c3c78e283ef38929ccc3c199e321cfe}{
\index{EventLoop@{EventLoop}!run@{run}}
\index{run@{run}!EventLoop@{EventLoop}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}void EventLoop::run (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classEventLoop_a6c3c78e283ef38929ccc3c199e321cfe}


Invoke all pending callbacks relating to \hyperlink{classXorpTimer}{XorpTimer} and file descriptor activity. 

This function may block if there are no selectors ready. It may block forever if there are no timers pending. The \hyperlink{classEventLoop_a9a7feb3e4c4707bfb71132ad080ca790}{timers\_\-pending} method can be used to detect whether there are timers pending, while \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop_ae818b87482aa87ca8e5b5d82603298e2}{events\_\-pending} method can be used to detect whether there any events pending. An event can be either timer or task. The \hyperlink{classEventLoop_acc537bd13d100f8daa0c990c44f5fdbe}{descriptor\_\-count} method can be used to see if there are any select'able file descriptors.


\begin{DoxyPre}
     \hyperlink{classEventLoop}{EventLoop} e;\end{DoxyPre}



\begin{DoxyPre}     ...\end{DoxyPre}



\begin{DoxyPre}     while(e.events\_pending() || e.descriptor\_count() > 0) \{
         e.run();
     \}\end{DoxyPre}



\begin{DoxyPre} \end{DoxyPre}


Non-\/xorp processes which use Xorp code should create a periodic timer to prevent \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop_a6c3c78e283ef38929ccc3c199e321cfe}{run()} function from blocking indefinitely when there are no pending \hyperlink{classXorpTimer}{XorpTimer} or SelectList objects. The period of \hyperlink{protocolthe-p}{the} timer will depend on \hyperlink{protocolthe-p}{the} application's existing needs.


\begin{DoxyPre}
     static bool wakeup\_hook(int n) \{
        static int count = 0;
	count += n;
	printf("count = %d\(\backslash\)n", n);
     	return true;
     \}\end{DoxyPre}



\begin{DoxyPre}     int main() \{
     	... // Program initialization\end{DoxyPre}



\begin{DoxyPre}Add a Xorp \hyperlink{classEventLoop}{EventLoop}
	\hyperlink{classEventLoop}{EventLoop} e;
	\hyperlink{classXorpTimer}{XorpTimer} wakeywakey = e.new\_periodic\_ms(100, callback(wakeup\_hook, 1));\end{DoxyPre}



\begin{DoxyPre}Program's main loop
	for(;;) \{
		... do what program does in its main loop ...
		e.run(); // process events
	\}
     \}
 \end{DoxyPre}
 \hypertarget{classEventLoop_a9760df4ca9212be2e9b37ce4618a838b}{
\index{EventLoop@{EventLoop}!selector\_\-list@{selector\_\-list}}
\index{selector\_\-list@{selector\_\-list}!EventLoop@{EventLoop}}
\subsubsection[{selector\_\-list}]{\setlength{\rightskip}{0pt plus 5cm}{\bf SelectorList}\& EventLoop::selector\_\-list (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a9760df4ca9212be2e9b37ce4618a838b}
\begin{DoxyReturn}{Returns}
reference to \hyperlink{protocolthe-p}{the} \hyperlink{classSelectorList}{SelectorList} used by \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop} instance. XXX: Deprecated. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a6af50845596fad9887990f775a5d5878}{
\index{EventLoop@{EventLoop}!set\_\-flag\_\-after@{set\_\-flag\_\-after}}
\index{set\_\-flag\_\-after@{set\_\-flag\_\-after}!EventLoop@{EventLoop}}
\subsubsection[{set\_\-flag\_\-after}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::set\_\-flag\_\-after (
\begin{DoxyParamCaption}
\item[{const {\bf TimeVal} \&}]{wait, }
\item[{bool $\ast$}]{flag\_\-ptr, }
\item[{bool}]{to\_\-value = {\ttfamily true}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a6af50845596fad9887990f775a5d5878}


Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em wait} & \hyperlink{protocolthe-p}{the} relative time when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em flag\_\-ptr} & pointer to a boolean variable that is to be set when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em to\_\-value} & value to set \hyperlink{protocolthe-p}{the} boolean variable to. Default value is true. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a7bbbfe464f416e07cb5ed2c342940ad1}{
\index{EventLoop@{EventLoop}!set\_\-flag\_\-after\_\-ms@{set\_\-flag\_\-after\_\-ms}}
\index{set\_\-flag\_\-after\_\-ms@{set\_\-flag\_\-after\_\-ms}!EventLoop@{EventLoop}}
\subsubsection[{set\_\-flag\_\-after\_\-ms}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::set\_\-flag\_\-after\_\-ms (
\begin{DoxyParamCaption}
\item[{int}]{ms, }
\item[{bool $\ast$}]{flag\_\-ptr, }
\item[{bool}]{to\_\-value = {\ttfamily true}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a7bbbfe464f416e07cb5ed2c342940ad1}


Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em ms} & \hyperlink{protocolthe-p}{the} relative time in millisecond when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em flag\_\-ptr} & pointer to a boolean variable that is set to false when this function is called and will be set to true when \hyperlink{protocolthe-p}{the} \hyperlink{classXorpTimer}{XorpTimer} expires. \\
\hline
{\em flag\_\-ptr} & pointer to a boolean variable that is to be set when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em to\_\-value} & value to set \hyperlink{protocolthe-p}{the} boolean variable to. Default value is true. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_afceb9b445c1e1547298cd8f3892b09f4}{
\index{EventLoop@{EventLoop}!set\_\-flag\_\-at@{set\_\-flag\_\-at}}
\index{set\_\-flag\_\-at@{set\_\-flag\_\-at}!EventLoop@{EventLoop}}
\subsubsection[{set\_\-flag\_\-at}]{\setlength{\rightskip}{0pt plus 5cm}{\bf XorpTimer} EventLoop::set\_\-flag\_\-at (
\begin{DoxyParamCaption}
\item[{const {\bf TimeVal} \&}]{when, }
\item[{bool $\ast$}]{flag\_\-ptr, }
\item[{bool}]{to\_\-value = {\ttfamily true}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_afceb9b445c1e1547298cd8f3892b09f4}


Add a flag setting timer to \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop}. 


\begin{DoxyParams}{Parameters}
{\em when} & \hyperlink{protocolthe-p}{the} absolute time when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em flag\_\-ptr} & pointer to a boolean variable that is to be set when \hyperlink{protocolthe-p}{the} timer expires. \\
\hline
{\em to\_\-value} & value to set \hyperlink{protocolthe-p}{the} boolean variable to. Default value is true. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a \hyperlink{classXorpTimer}{XorpTimer} object that must be assigned to remain scheduled. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a9eea92ae27a8c95ad91158ffdbb7a40b}{
\index{EventLoop@{EventLoop}!timer\_\-list@{timer\_\-list}}
\index{timer\_\-list@{timer\_\-list}!EventLoop@{EventLoop}}
\subsubsection[{timer\_\-list}]{\setlength{\rightskip}{0pt plus 5cm}{\bf TimerList}\& EventLoop::timer\_\-list (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a9eea92ae27a8c95ad91158ffdbb7a40b}
\begin{DoxyReturn}{Returns}
reference to \hyperlink{protocolthe-p}{the} \hyperlink{classTimerList}{TimerList} used by \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop} instance. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a18fbbc043297869768a25612da88ca6f}{
\index{EventLoop@{EventLoop}!timer\_\-list\_\-length@{timer\_\-list\_\-length}}
\index{timer\_\-list\_\-length@{timer\_\-list\_\-length}!EventLoop@{EventLoop}}
\subsubsection[{timer\_\-list\_\-length}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t EventLoop::timer\_\-list\_\-length (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a18fbbc043297869768a25612da88ca6f}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} number of XorpTimers present on EventLoop's \hyperlink{classTimerList}{TimerList}. 
\end{DoxyReturn}
\hypertarget{classEventLoop_a9a7feb3e4c4707bfb71132ad080ca790}{
\index{EventLoop@{EventLoop}!timers\_\-pending@{timers\_\-pending}}
\index{timers\_\-pending@{timers\_\-pending}!EventLoop@{EventLoop}}
\subsubsection[{timers\_\-pending}]{\setlength{\rightskip}{0pt plus 5cm}bool EventLoop::timers\_\-pending (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classEventLoop_a9a7feb3e4c4707bfb71132ad080ca790}
\begin{DoxyReturn}{Returns}
true if any XorpTimers are present on EventLoop's \hyperlink{classTimerList}{TimerList}. 
\end{DoxyReturn}


The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/eventloop.hh\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/eventloop.cc\end{DoxyCompactItemize}
