\hypertarget{classSelectorList}{
\section{SelectorList Class Reference}
\label{classSelectorList}\index{SelectorList@{SelectorList}}
}


A class to provide an interface to I/O multiplexing.  




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

Inheritance diagram for SelectorList:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classSelectorList}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structSelectorList_1_1Node}{Node}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSelectorList_ae0f053f0dd8b3ecc865b2ff7c4d94f2c}{
\hyperlink{classSelectorList_ae0f053f0dd8b3ecc865b2ff7c4d94f2c}{SelectorList} (\hyperlink{classClockBase}{ClockBase} $\ast$clock)}
\label{classSelectorList_ae0f053f0dd8b3ecc865b2ff7c4d94f2c}

\begin{DoxyCompactList}\small\item\em Default constructor. \item\end{DoxyCompactList}\item 
\hypertarget{classSelectorList_a9151110d41bc9b9dccd4ca2eaf3bc2bb}{
virtual \hyperlink{classSelectorList_a9151110d41bc9b9dccd4ca2eaf3bc2bb}{$\sim$SelectorList} ()}
\label{classSelectorList_a9151110d41bc9b9dccd4ca2eaf3bc2bb}

\begin{DoxyCompactList}\small\item\em Destructor. \item\end{DoxyCompactList}\item 
\hypertarget{classSelectorList_a5bdef7e2d6bb7e4d43b21efc828cae10}{
void {\bfseries set\_\-debug} (bool v)}
\label{classSelectorList_a5bdef7e2d6bb7e4d43b21efc828cae10}

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

\item 
bool \hyperlink{classSelectorList_a8084225d14871efdac4c7ed3562895a5}{add\_\-ioevent\_\-cb} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type, const IoEventCb \&cb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Add a hook for pending I/O operations on a callback. \item\end{DoxyCompactList}\item 
void \hyperlink{classSelectorList_a814dc771332ec5c655c190254fc7141d}{remove\_\-ioevent\_\-cb} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type=IOT\_\-ANY)
\begin{DoxyCompactList}\small\item\em Remove hooks for pending I/O operations. \item\end{DoxyCompactList}\item 
bool \hyperlink{classSelectorList_ac0ee580558f14687d3c414c648618d0b}{ready} ()
\begin{DoxyCompactList}\small\item\em Find out if any of \hyperlink{protocolthe-p}{the} selectors are ready. \item\end{DoxyCompactList}\item 
int \hyperlink{classSelectorList_a4b35296a1271be53bf4ce66daafe8d06}{get\_\-ready\_\-priority} (bool force)
\begin{DoxyCompactList}\small\item\em Find out \hyperlink{protocolthe-p}{the} highest priority from \hyperlink{protocolthe-p}{the} ready file descriptors. \item\end{DoxyCompactList}\item 
int \hyperlink{classSelectorList_a7801249656d58503bf1ad27c6caed7fb}{wait\_\-and\_\-dispatch} (\hyperlink{classTimeVal}{TimeVal} \&timeout)
\begin{DoxyCompactList}\small\item\em Wait for a pending I/O events and invoke callbacks when they become ready. \item\end{DoxyCompactList}\item 
int \hyperlink{classSelectorList_a8c2e5f678680fffa8ef6aa5803a744a1}{wait\_\-and\_\-dispatch} (int millisecs)
\begin{DoxyCompactList}\small\item\em Wait for a pending I/O events and invoke callbacks when they become ready. \item\end{DoxyCompactList}\item 
size\_\-t \hyperlink{classSelectorList_a206103de42efe78c6bf2ed3d08065cf8}{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 
void \hyperlink{classSelectorList_a2435f18c9f8df9a7a8ca849d3dc2371c}{get\_\-fd\_\-set} (SelectorMask selected\_\-mask, fd\_\-set \&fds) const 
\begin{DoxyCompactList}\small\item\em Get a copy of \hyperlink{protocolthe-p}{the} current list of monitored file descriptors in Unix fd\_\-set format. \item\end{DoxyCompactList}\item 
int \hyperlink{classSelectorList_a3410043f3d7109cc50bfb2502ffba850}{get\_\-max\_\-fd} () const 
\begin{DoxyCompactList}\small\item\em Get a \hyperlink{protocolthe-p}{the} value of \hyperlink{protocolthe-p}{the} largest monitored file descriptor. \item\end{DoxyCompactList}\item 
void \hyperlink{classSelectorList_a259f5466b0ac542116fb6c72d78d4031}{set\_\-observer} (\hyperlink{classSelectorListObserverBase}{SelectorListObserverBase} \&obs)
\begin{DoxyCompactList}\small\item\em Set \hyperlink{protocolthe-p}{the} SelectorObserver object that will receive notifications. \item\end{DoxyCompactList}\item 
void \hyperlink{classSelectorList_a10623f85337c256b9facaa759153facf}{remove\_\-observer} ()
\begin{DoxyCompactList}\small\item\em Remove \hyperlink{protocolthe-p}{the} SelectorObserver object that receives notifications. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSelectorList_ab595c1f704fdff48ab6d97c691988c7f}{
void {\bfseries callback\_\-bad\_\-descriptors} ()}
\label{classSelectorList_ab595c1f704fdff48ab6d97c691988c7f}

\end{DoxyCompactItemize}
\subsection*{Private Types}
\begin{DoxyCompactItemize}
\item 
enum \{ {\bfseries SEL\_\-RD\_\-IDX} =  0, 
{\bfseries SEL\_\-WR\_\-IDX} =  1, 
{\bfseries SEL\_\-EX\_\-IDX} =  2, 
{\bfseries SEL\_\-MAX\_\-IDX} =  3
 \}
\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classSelectorList_ae71e97fddd3eabd51cfd9f2e232f0af7}{
int {\bfseries do\_\-select} (struct timeval $\ast$to, bool force)}
\label{classSelectorList_ae71e97fddd3eabd51cfd9f2e232f0af7}

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

\item 
\hypertarget{classSelectorList_a2c27e91aafca49bdae38812d2d850893}{
\hyperlink{classSelectorListObserverBase}{SelectorListObserverBase} $\ast$ {\bfseries \_\-observer}}
\label{classSelectorList_a2c27e91aafca49bdae38812d2d850893}

\item 
\hypertarget{classSelectorList_a0bd18290309497df7ab11f80e46e6f0a}{
fd\_\-set {\bfseries \_\-fds} \mbox{[}SEL\_\-MAX\_\-IDX\mbox{]}}
\label{classSelectorList_a0bd18290309497df7ab11f80e46e6f0a}

\item 
\hypertarget{classSelectorList_a09954e321dd947bc507a865cd0f21289}{
fd\_\-set {\bfseries \_\-testfds} \mbox{[}SEL\_\-MAX\_\-IDX\mbox{]}}
\label{classSelectorList_a09954e321dd947bc507a865cd0f21289}

\item 
\hypertarget{classSelectorList_a19a1547eb4856ae36348a3886660783f}{
int {\bfseries \_\-testfds\_\-n}}
\label{classSelectorList_a19a1547eb4856ae36348a3886660783f}

\item 
\hypertarget{classSelectorList_a28245234eb3e58c3460b9d1ed281f60e}{
int {\bfseries \_\-maxpri\_\-fd}}
\label{classSelectorList_a28245234eb3e58c3460b9d1ed281f60e}

\item 
\hypertarget{classSelectorList_a40f610682f25295317e0696b290a63f6}{
int {\bfseries \_\-maxpri\_\-sel}}
\label{classSelectorList_a40f610682f25295317e0696b290a63f6}

\item 
\hypertarget{classSelectorList_a686d16ab44c7544f54ee4cf0365c02c2}{
int {\bfseries \_\-last\_\-served\_\-fd}}
\label{classSelectorList_a686d16ab44c7544f54ee4cf0365c02c2}

\item 
\hypertarget{classSelectorList_a622d82921f69d3551fae427e9ba8a8d8}{
int {\bfseries \_\-last\_\-served\_\-sel}}
\label{classSelectorList_a622d82921f69d3551fae427e9ba8a8d8}

\item 
\hypertarget{classSelectorList_a06636088d6a3293073446a850f681500}{
vector$<$ \hyperlink{structSelectorList_1_1Node}{Node} $>$ {\bfseries \_\-selector\_\-entries}}
\label{classSelectorList_a06636088d6a3293073446a850f681500}

\item 
\hypertarget{classSelectorList_ad0c024f00ada73a1d521f7781b9b3349}{
int {\bfseries \_\-maxfd}}
\label{classSelectorList_ad0c024f00ada73a1d521f7781b9b3349}

\item 
\hypertarget{classSelectorList_afc390f311fb2559222529a75ea934b67}{
size\_\-t {\bfseries \_\-descriptor\_\-count}}
\label{classSelectorList_afc390f311fb2559222529a75ea934b67}

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

\end{DoxyCompactItemize}


\subsection{Detailed Description}
A class to provide an interface to I/O multiplexing. A \hyperlink{classSelectorList}{SelectorList} provides an entity where callbacks for pending I/O operations on file descriptors may be registered. The callbacks are invoked when one of \hyperlink{protocolthe-p}{the} \hyperlink{classSelectorList_a7801249656d58503bf1ad27c6caed7fb}{wait\_\-and\_\-dispatch} methods is called and I/O is pending on \hyperlink{protocolthe-p}{the} particular descriptors. 

\subsection{Member Function Documentation}
\hypertarget{classSelectorList_a8084225d14871efdac4c7ed3562895a5}{
\index{SelectorList@{SelectorList}!add\_\-ioevent\_\-cb@{add\_\-ioevent\_\-cb}}
\index{add\_\-ioevent\_\-cb@{add\_\-ioevent\_\-cb}!SelectorList@{SelectorList}}
\subsubsection[{add\_\-ioevent\_\-cb}]{\setlength{\rightskip}{0pt plus 5cm}bool SelectorList::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{classSelectorList_a8084225d14871efdac4c7ed3562895a5}


Add a hook for pending I/O operations on a callback. 

Only one callback may be registered for each possible I/O event type (read, write, exception).

Multiple event types may share \hyperlink{protocolthe-p}{the} same callback. If multiple event types share \hyperlink{protocolthe-p}{the} same callback and multiple types of event are pending, \hyperlink{protocolthe-p}{the} callback is invoked just once and \hyperlink{protocolthe-p}{the} mask argument to \hyperlink{protocolthe-p}{the} callback shows which events are pending.


\begin{DoxyParams}{Parameters}
{\em file} & descriptor.\\
\hline
{\em mask} & mask of I/O event types that should invoke callback. An OR'ed combination of \hyperlink{protocolthe-p}{the} available SelectorMask values.\\
\hline
{\em scb} & callback object that will be invoked when \hyperlink{protocolthe-p}{the} descriptor.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if function succeeds, false otherwise. 
\end{DoxyReturn}
\hypertarget{classSelectorList_a206103de42efe78c6bf2ed3d08065cf8}{
\index{SelectorList@{SelectorList}!descriptor\_\-count@{descriptor\_\-count}}
\index{descriptor\_\-count@{descriptor\_\-count}!SelectorList@{SelectorList}}
\subsubsection[{descriptor\_\-count}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t SelectorList::descriptor\_\-count (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classSelectorList_a206103de42efe78c6bf2ed3d08065cf8}


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{classSelectorList_a2435f18c9f8df9a7a8ca849d3dc2371c}{
\index{SelectorList@{SelectorList}!get\_\-fd\_\-set@{get\_\-fd\_\-set}}
\index{get\_\-fd\_\-set@{get\_\-fd\_\-set}!SelectorList@{SelectorList}}
\subsubsection[{get\_\-fd\_\-set}]{\setlength{\rightskip}{0pt plus 5cm}void SelectorList::get\_\-fd\_\-set (
\begin{DoxyParamCaption}
\item[{SelectorMask}]{selected\_\-mask, }
\item[{fd\_\-set \&}]{fds}
\end{DoxyParamCaption}
) const}}
\label{classSelectorList_a2435f18c9f8df9a7a8ca849d3dc2371c}


Get a copy of \hyperlink{protocolthe-p}{the} current list of monitored file descriptors in Unix fd\_\-set format. 


\begin{DoxyParams}{Parameters}
{\em \hyperlink{protocolthe-p}{the}} & selected mask as SelectorMask (SEL\_\-RD, SEL\_\-WR, or SEL\_\-EX)\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} selected fd\_\-set. 
\end{DoxyReturn}
\hypertarget{classSelectorList_a3410043f3d7109cc50bfb2502ffba850}{
\index{SelectorList@{SelectorList}!get\_\-max\_\-fd@{get\_\-max\_\-fd}}
\index{get\_\-max\_\-fd@{get\_\-max\_\-fd}!SelectorList@{SelectorList}}
\subsubsection[{get\_\-max\_\-fd}]{\setlength{\rightskip}{0pt plus 5cm}int SelectorList::get\_\-max\_\-fd (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}
\label{classSelectorList_a3410043f3d7109cc50bfb2502ffba850}


Get a \hyperlink{protocolthe-p}{the} value of \hyperlink{protocolthe-p}{the} largest monitored file descriptor. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} maximum fd. 
\end{DoxyReturn}
\hypertarget{classSelectorList_a4b35296a1271be53bf4ce66daafe8d06}{
\index{SelectorList@{SelectorList}!get\_\-ready\_\-priority@{get\_\-ready\_\-priority}}
\index{get\_\-ready\_\-priority@{get\_\-ready\_\-priority}!SelectorList@{SelectorList}}
\subsubsection[{get\_\-ready\_\-priority}]{\setlength{\rightskip}{0pt plus 5cm}int SelectorList::get\_\-ready\_\-priority (
\begin{DoxyParamCaption}
\item[{bool}]{force}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a4b35296a1271be53bf4ce66daafe8d06}


Find out \hyperlink{protocolthe-p}{the} highest priority from \hyperlink{protocolthe-p}{the} ready file descriptors. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} priority of \hyperlink{protocolthe-p}{the} highest priority ready file descriptor. 
\end{DoxyReturn}
\hypertarget{classSelectorList_ac0ee580558f14687d3c414c648618d0b}{
\index{SelectorList@{SelectorList}!ready@{ready}}
\index{ready@{ready}!SelectorList@{SelectorList}}
\subsubsection[{ready}]{\setlength{\rightskip}{0pt plus 5cm}bool SelectorList::ready (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_ac0ee580558f14687d3c414c648618d0b}


Find out if any of \hyperlink{protocolthe-p}{the} selectors are ready. 

\begin{DoxyReturn}{Returns}
true if any selector is ready. 
\end{DoxyReturn}
\hypertarget{classSelectorList_a814dc771332ec5c655c190254fc7141d}{
\index{SelectorList@{SelectorList}!remove\_\-ioevent\_\-cb@{remove\_\-ioevent\_\-cb}}
\index{remove\_\-ioevent\_\-cb@{remove\_\-ioevent\_\-cb}!SelectorList@{SelectorList}}
\subsubsection[{remove\_\-ioevent\_\-cb}]{\setlength{\rightskip}{0pt plus 5cm}void SelectorList::remove\_\-ioevent\_\-cb (
\begin{DoxyParamCaption}
\item[{{\bf XorpFd}}]{fd, }
\item[{IoEventType}]{type = {\ttfamily IOT\_\-ANY}}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a814dc771332ec5c655c190254fc7141d}


Remove hooks for pending I/O operations. 


\begin{DoxyParams}{Parameters}
{\em fd} & \hyperlink{protocolthe-p}{the} file descriptor.\\
\hline
{\em mask} & of event types to be removed, e.g. an OR'ed combination of \hyperlink{protocolthe-p}{the} available SelectorMask values. \\
\hline
\end{DoxyParams}
\hypertarget{classSelectorList_a10623f85337c256b9facaa759153facf}{
\index{SelectorList@{SelectorList}!remove\_\-observer@{remove\_\-observer}}
\index{remove\_\-observer@{remove\_\-observer}!SelectorList@{SelectorList}}
\subsubsection[{remove\_\-observer}]{\setlength{\rightskip}{0pt plus 5cm}void SelectorList::remove\_\-observer (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a10623f85337c256b9facaa759153facf}


Remove \hyperlink{protocolthe-p}{the} SelectorObserver object that receives notifications. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}
\hypertarget{classSelectorList_a259f5466b0ac542116fb6c72d78d4031}{
\index{SelectorList@{SelectorList}!set\_\-observer@{set\_\-observer}}
\index{set\_\-observer@{set\_\-observer}!SelectorList@{SelectorList}}
\subsubsection[{set\_\-observer}]{\setlength{\rightskip}{0pt plus 5cm}void SelectorList::set\_\-observer (
\begin{DoxyParamCaption}
\item[{{\bf SelectorListObserverBase} \&}]{obs}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a259f5466b0ac542116fb6c72d78d4031}


Set \hyperlink{protocolthe-p}{the} SelectorObserver object that will receive notifications. 

\begin{DoxyReturn}{Returns}
void 
\end{DoxyReturn}
\hypertarget{classSelectorList_a7801249656d58503bf1ad27c6caed7fb}{
\index{SelectorList@{SelectorList}!wait\_\-and\_\-dispatch@{wait\_\-and\_\-dispatch}}
\index{wait\_\-and\_\-dispatch@{wait\_\-and\_\-dispatch}!SelectorList@{SelectorList}}
\subsubsection[{wait\_\-and\_\-dispatch}]{\setlength{\rightskip}{0pt plus 5cm}int SelectorList::wait\_\-and\_\-dispatch (
\begin{DoxyParamCaption}
\item[{{\bf TimeVal} \&}]{timeout}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a7801249656d58503bf1ad27c6caed7fb}


Wait for a pending I/O events and invoke callbacks when they become ready. 


\begin{DoxyParams}{Parameters}
{\em timeout} & \hyperlink{protocolthe-p}{the} maximum period to wait for.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} number of callbacks that were made. 
\end{DoxyReturn}
\hypertarget{classSelectorList_a8c2e5f678680fffa8ef6aa5803a744a1}{
\index{SelectorList@{SelectorList}!wait\_\-and\_\-dispatch@{wait\_\-and\_\-dispatch}}
\index{wait\_\-and\_\-dispatch@{wait\_\-and\_\-dispatch}!SelectorList@{SelectorList}}
\subsubsection[{wait\_\-and\_\-dispatch}]{\setlength{\rightskip}{0pt plus 5cm}int SelectorList::wait\_\-and\_\-dispatch (
\begin{DoxyParamCaption}
\item[{int}]{millisecs}
\end{DoxyParamCaption}
)}}
\label{classSelectorList_a8c2e5f678680fffa8ef6aa5803a744a1}


Wait for a pending I/O events and invoke callbacks when they become ready. 


\begin{DoxyParams}{Parameters}
{\em millisecs} & \hyperlink{protocolthe-p}{the} maximum period in milliseconds to wait for.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} number of callbacks that were made. 
\end{DoxyReturn}


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