\hypertarget{classBufferedAsyncReader}{
\section{BufferedAsyncReader Class Reference}
\label{classBufferedAsyncReader}\index{BufferedAsyncReader@{BufferedAsyncReader}}
}
Inheritance diagram for BufferedAsyncReader:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classBufferedAsyncReader}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structBufferedAsyncReader_1_1Config}{Config}
\end{DoxyCompactItemize}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
enum {\bfseries Event} \{ {\bfseries DATA} =  1, 
{\bfseries OS\_\-ERROR} =  2, 
{\bfseries END\_\-OF\_\-FILE} =  3
 \}
\item 
\hypertarget{classBufferedAsyncReader_a2fe29183c5e595df3875d45a6efd6b66}{
typedef XorpCallback4$<$ void, \hyperlink{classBufferedAsyncReader}{BufferedAsyncReader} $\ast$, Event, uint8\_\-t $\ast$, size\_\-t $>$::RefPtr {\bfseries Callback}}
\label{classBufferedAsyncReader_a2fe29183c5e595df3875d45a6efd6b66}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classBufferedAsyncReader_af83ca732a6ef06a56f751fdab9342347}{BufferedAsyncReader} (\hyperlink{classEventLoop}{EventLoop} \&e, \hyperlink{classXorpFd}{XorpFd} fd, size\_\-t reserve\_\-bytes, const Callback \&cb, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\begin{DoxyCompactList}\small\item\em Constructor. \item\end{DoxyCompactList}\item 
bool \hyperlink{classBufferedAsyncReader_a75a8614012087ded8176871b107647a6}{set\_\-trigger\_\-bytes} (size\_\-t bytes)
\begin{DoxyCompactList}\small\item\em Set threshold for event notification. \item\end{DoxyCompactList}\item 
\hypertarget{classBufferedAsyncReader_afdf91baa7dee6ee881699aa2752e5916}{
size\_\-t \hyperlink{classBufferedAsyncReader_afdf91baa7dee6ee881699aa2752e5916}{trigger\_\-bytes} () const }
\label{classBufferedAsyncReader_afdf91baa7dee6ee881699aa2752e5916}

\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} current threshold for event notification. \item\end{DoxyCompactList}\item 
bool \hyperlink{classBufferedAsyncReader_a34876bec0e3d4e0f8cb036e65dbaa2f1}{dispose} (size\_\-t bytes)
\begin{DoxyCompactList}\small\item\em Acknowledge data at \hyperlink{protocolthe-p}{the} start of \hyperlink{protocolthe-p}{the} buffer is finished with. \item\end{DoxyCompactList}\item 
bool \hyperlink{classBufferedAsyncReader_a3fd949e8560251f5ce9a266efa4a637d}{set\_\-reserve\_\-bytes} (size\_\-t bytes)
\begin{DoxyCompactList}\small\item\em Set reserve for maximum amount of data to receive. \item\end{DoxyCompactList}\item 
\hypertarget{classBufferedAsyncReader_a63a871f9676fec30516427910742e2c4}{
size\_\-t \hyperlink{classBufferedAsyncReader_a63a871f9676fec30516427910742e2c4}{reserve\_\-bytes} () const }
\label{classBufferedAsyncReader_a63a871f9676fec30516427910742e2c4}

\begin{DoxyCompactList}\small\item\em Get reserve for maximum amount of data to receive. \item\end{DoxyCompactList}\item 
\hypertarget{classBufferedAsyncReader_a004e4c01d1b3af2492cae2a6664f9d2f}{
size\_\-t \hyperlink{classBufferedAsyncReader_a004e4c01d1b3af2492cae2a6664f9d2f}{available\_\-bytes} () const }
\label{classBufferedAsyncReader_a004e4c01d1b3af2492cae2a6664f9d2f}

\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} number of currently available bytes. \item\end{DoxyCompactList}\item 
\hypertarget{classBufferedAsyncReader_acf5a9ae29550ded29a5a8cc44dfacbba}{
int {\bfseries error} () const }
\label{classBufferedAsyncReader_acf5a9ae29550ded29a5a8cc44dfacbba}

\item 
void \hyperlink{classBufferedAsyncReader_a56bba55f31af6984d57891ed1bbaccb4}{start} ()
\begin{DoxyCompactList}\small\item\em Start. \item\end{DoxyCompactList}\item 
void \hyperlink{classBufferedAsyncReader_a9187f8e8e240c49dad046b9448db38c5}{stop} ()
\begin{DoxyCompactList}\small\item\em Stop. \item\end{DoxyCompactList}\item 
\hypertarget{classBufferedAsyncReader_ad0ab6efb1ccf01f56475c4beaf1ea3be}{
virtual string {\bfseries toString} () const }
\label{classBufferedAsyncReader_ad0ab6efb1ccf01f56475c4beaf1ea3be}

\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classBufferedAsyncReader_ae7a1b3bcbad1c199fb3e77d78d357030}{
void {\bfseries io\_\-event} (\hyperlink{classXorpFd}{XorpFd} fd, IoEventType type)}
\label{classBufferedAsyncReader_ae7a1b3bcbad1c199fb3e77d78d357030}

\item 
\hypertarget{classBufferedAsyncReader_ad295ea2ff11267a5fd1735443e0bb80d}{
void {\bfseries announce\_\-event} (Event e)}
\label{classBufferedAsyncReader_ad295ea2ff11267a5fd1735443e0bb80d}

\item 
\hypertarget{classBufferedAsyncReader_ad76ad56870ad641f909ea38a16a0fe33}{
void {\bfseries provision\_\-trigger\_\-bytes} ()}
\label{classBufferedAsyncReader_ad76ad56870ad641f909ea38a16a0fe33}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classBufferedAsyncReader_a50399df511861b83acc574f9a7811b63}{
\hyperlink{structBufferedAsyncReader_1_1Config}{Config} {\bfseries \_\-config}}
\label{classBufferedAsyncReader_a50399df511861b83acc574f9a7811b63}

\item 
\hypertarget{classBufferedAsyncReader_adb2cb6f6706a899e38b5196ee77e01fd}{
\hyperlink{classEventLoop}{EventLoop} \& {\bfseries \_\-eventloop}}
\label{classBufferedAsyncReader_adb2cb6f6706a899e38b5196ee77e01fd}

\item 
\hypertarget{classBufferedAsyncReader_a880488eb1c13f2e499aaa2b690234b75}{
\hyperlink{classXorpFd}{XorpFd} {\bfseries \_\-fd}}
\label{classBufferedAsyncReader_a880488eb1c13f2e499aaa2b690234b75}

\item 
\hypertarget{classBufferedAsyncReader_a344e4780535c036816633d910fd25269}{
Callback {\bfseries \_\-cb}}
\label{classBufferedAsyncReader_a344e4780535c036816633d910fd25269}

\item 
\hypertarget{classBufferedAsyncReader_aa86c36f3f33f01dcd016ea311bb80c8f}{
vector$<$ uint8\_\-t $>$ {\bfseries \_\-buffer}}
\label{classBufferedAsyncReader_aa86c36f3f33f01dcd016ea311bb80c8f}

\item 
\hypertarget{classBufferedAsyncReader_a35d82b889e94068bb886687fc83b5d87}{
\hyperlink{classXorpTimer}{XorpTimer} {\bfseries \_\-ready\_\-timer}}
\label{classBufferedAsyncReader_a35d82b889e94068bb886687fc83b5d87}

\item 
\hypertarget{classBufferedAsyncReader_a12cc89a2147162aa693dd2816bb25d05}{
int {\bfseries \_\-last\_\-error}}
\label{classBufferedAsyncReader_a12cc89a2147162aa693dd2816bb25d05}

\item 
\hypertarget{classBufferedAsyncReader_af5774be267a2f1aef0790451d3c03144}{
int {\bfseries \_\-priority}}
\label{classBufferedAsyncReader_af5774be267a2f1aef0790451d3c03144}

\end{DoxyCompactItemize}


\subsection{Constructor \& Destructor Documentation}
\hypertarget{classBufferedAsyncReader_af83ca732a6ef06a56f751fdab9342347}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!BufferedAsyncReader@{BufferedAsyncReader}}
\index{BufferedAsyncReader@{BufferedAsyncReader}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{BufferedAsyncReader}]{\setlength{\rightskip}{0pt plus 5cm}BufferedAsyncReader::BufferedAsyncReader (
\begin{DoxyParamCaption}
\item[{{\bf EventLoop} \&}]{e, }
\item[{{\bf XorpFd}}]{fd, }
\item[{size\_\-t}]{reserve\_\-bytes, }
\item[{const Callback \&}]{cb, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_af83ca732a6ef06a56f751fdab9342347}


Constructor. 


\begin{DoxyParams}{Parameters}
{\em e} & \hyperlink{protocolthe-p}{the} eventloop. \\
\hline
{\em fd} & \hyperlink{protocolthe-p}{the} file descriptor. \\
\hline
{\em reserve\_\-bytes} & \hyperlink{protocolthe-p}{the} number of bytes to reserve in \hyperlink{protocolthe-p}{the} data buffer. \\
\hline
{\em cb} & \hyperlink{protocolthe-p}{the} callback to invoke. \\
\hline
{\em priority} & \hyperlink{protocolthe-p}{the} task priority for \hyperlink{protocolthe-p}{the} eventloop operations. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\hypertarget{classBufferedAsyncReader_a34876bec0e3d4e0f8cb036e65dbaa2f1}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!dispose@{dispose}}
\index{dispose@{dispose}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{dispose}]{\setlength{\rightskip}{0pt plus 5cm}bool BufferedAsyncReader::dispose (
\begin{DoxyParamCaption}
\item[{size\_\-t}]{bytes}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_a34876bec0e3d4e0f8cb036e65dbaa2f1}


Acknowledge data at \hyperlink{protocolthe-p}{the} start of \hyperlink{protocolthe-p}{the} buffer is finished with. 

Typically, a consumer would call this from within their callback to say this number of bytes has been processed and can be discarded.


\begin{DoxyParams}{Parameters}
{\em bytes} & \hyperlink{protocolthe-p}{the} number of bytes to dispose. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if bytes is larger than \hyperlink{protocolthe-p}{the} number of available bytes. 
\end{DoxyReturn}
\hypertarget{classBufferedAsyncReader_a3fd949e8560251f5ce9a266efa4a637d}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!set\_\-reserve\_\-bytes@{set\_\-reserve\_\-bytes}}
\index{set\_\-reserve\_\-bytes@{set\_\-reserve\_\-bytes}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{set\_\-reserve\_\-bytes}]{\setlength{\rightskip}{0pt plus 5cm}bool BufferedAsyncReader::set\_\-reserve\_\-bytes (
\begin{DoxyParamCaption}
\item[{size\_\-t}]{bytes}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_a3fd949e8560251f5ce9a266efa4a637d}


Set reserve for maximum amount of data to receive. 


\begin{DoxyParams}{Parameters}
{\em bytes} & \hyperlink{protocolthe-p}{the} number of bytes to reserve. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if error. 
\end{DoxyReturn}
\hypertarget{classBufferedAsyncReader_a75a8614012087ded8176871b107647a6}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!set\_\-trigger\_\-bytes@{set\_\-trigger\_\-bytes}}
\index{set\_\-trigger\_\-bytes@{set\_\-trigger\_\-bytes}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{set\_\-trigger\_\-bytes}]{\setlength{\rightskip}{0pt plus 5cm}bool BufferedAsyncReader::set\_\-trigger\_\-bytes (
\begin{DoxyParamCaption}
\item[{size\_\-t}]{bytes}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_a75a8614012087ded8176871b107647a6}


Set threshold for event notification. 

Only when this threshold is reached \hyperlink{protocolthe-p}{the} consumers callback invoked. If more data is already available, then \hyperlink{protocolthe-p}{the} event notification will be triggered through a 0 second timer. This provides an opportunity for other tasks to run.

Calling this method may cause \hyperlink{protocolthe-p}{the} internal buffer state to change. If it is called from within a consumer callback, then \hyperlink{protocolthe-p}{the} buffer pointer may become invalid and dereferencing \hyperlink{protocolthe-p}{the} pointer should be avoided.


\begin{DoxyParams}{Parameters}
{\em bytes} & \hyperlink{protocolthe-p}{the} number of threshold bytes. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if bytes is larger than reserve. 
\end{DoxyReturn}
\hypertarget{classBufferedAsyncReader_a56bba55f31af6984d57891ed1bbaccb4}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!start@{start}}
\index{start@{start}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}void BufferedAsyncReader::start (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_a56bba55f31af6984d57891ed1bbaccb4}


Start. 

Start asynchrous reads. \hypertarget{classBufferedAsyncReader_a9187f8e8e240c49dad046b9448db38c5}{
\index{BufferedAsyncReader@{BufferedAsyncReader}!stop@{stop}}
\index{stop@{stop}!BufferedAsyncReader@{BufferedAsyncReader}}
\subsubsection[{stop}]{\setlength{\rightskip}{0pt plus 5cm}void BufferedAsyncReader::stop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{classBufferedAsyncReader_a9187f8e8e240c49dad046b9448db38c5}


Stop. 

Stop asynchrous reading. 

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