\hypertarget{classAsyncFileWriter}{
\section{AsyncFileWriter Class Reference}
\label{classAsyncFileWriter}\index{AsyncFileWriter@{AsyncFileWriter}}
}


Write asynchronously to non-\/blocking file.  




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

Inheritance diagram for AsyncFileWriter:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{classAsyncFileWriter}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{classAsyncFileWriter_1_1BufferInfo}{BufferInfo}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classAsyncFileWriter_ae87fb8de6088f4db160512aed5014166}{AsyncFileWriter} (\hyperlink{classEventLoop}{EventLoop} \&e, \hyperlink{classXorpFd}{XorpFd} fd, uint32\_\-t coalesce=1, int priority=XorpTask::PRIORITY\_\-DEFAULT)
\item 
void \hyperlink{classAsyncFileWriter_aa764f751bb6e2915cbc8c198da4c667e}{add\_\-buffer} (const uint8\_\-t $\ast$buffer, size\_\-t buffer\_\-bytes, const \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback} \&cb)
\begin{DoxyCompactList}\small\item\em Add an additional buffer for writing from. \item\end{DoxyCompactList}\item 
void \hyperlink{classAsyncFileWriter_ac6a430573083664e114875f607db959b}{add\_\-buffer\_\-sendto} (const uint8\_\-t $\ast$buffer, size\_\-t buffer\_\-bytes, const \hyperlink{classIPvX}{IPvX} \&dst\_\-addr, uint16\_\-t dst\_\-port, const \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback} \&cb)
\begin{DoxyCompactList}\small\item\em Add an additional buffer for writing from by using sendto(2). \item\end{DoxyCompactList}\item 
void \hyperlink{classAsyncFileWriter_a9ea8e13526ddde93820d63f5aecd7ae8}{add\_\-buffer\_\-with\_\-offset} (const uint8\_\-t $\ast$buffer, size\_\-t buffer\_\-bytes, size\_\-t offset, const \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback} \&cb)
\begin{DoxyCompactList}\small\item\em Add an additional buffer for writing from. \item\end{DoxyCompactList}\item 
void \hyperlink{classAsyncFileWriter_a399fe1214b7c5af7c0b327ee0053f524}{add\_\-data} (const vector$<$ uint8\_\-t $>$ \&data, const \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback} \&cb)
\begin{DoxyCompactList}\small\item\em Add additional data for writing from. \item\end{DoxyCompactList}\item 
void \hyperlink{classAsyncFileWriter_ad478c70c687f2d72403ff7cca9ea901d}{add\_\-data\_\-sendto} (const vector$<$ uint8\_\-t $>$ \&data, const \hyperlink{classIPvX}{IPvX} \&dst\_\-addr, uint16\_\-t dst\_\-port, const \hyperlink{classAsyncFileOperator_a12e626e2da12221a9f4333df89ad9ffe}{Callback} \&cb)
\begin{DoxyCompactList}\small\item\em Add additional data for writing from by using sendto(2). \item\end{DoxyCompactList}\item 
bool \hyperlink{classAsyncFileWriter_ab6f927fca413e15ac677743499ac0d5e}{start} ()
\begin{DoxyCompactList}\small\item\em Start asynchronous operation. \item\end{DoxyCompactList}\item 
\hypertarget{classAsyncFileWriter_ae06319acf8e6c6bf488e7fff1efe0fd3}{
void \hyperlink{classAsyncFileWriter_ae06319acf8e6c6bf488e7fff1efe0fd3}{stop} ()}
\label{classAsyncFileWriter_ae06319acf8e6c6bf488e7fff1efe0fd3}

\begin{DoxyCompactList}\small\item\em Stop asynchronous operation. \item\end{DoxyCompactList}\item 
size\_\-t \hyperlink{classAsyncFileWriter_ae3fb9be3ef862457a14fda48b58cea7b}{buffers\_\-remaining} () const 
\item 
\hypertarget{classAsyncFileWriter_a8e54ef606d3af0989ec2451c04bf2f8d}{
void \hyperlink{classAsyncFileWriter_a8e54ef606d3af0989ec2451c04bf2f8d}{flush\_\-buffers} ()}
\label{classAsyncFileWriter_a8e54ef606d3af0989ec2451c04bf2f8d}

\begin{DoxyCompactList}\small\item\em Stop asynchronous operation and clear list of buffers. \item\end{DoxyCompactList}\item 
\hypertarget{classAsyncFileWriter_ad1d359d953b88fb07bd6e9d7b593339f}{
virtual string {\bfseries toString} () const }
\label{classAsyncFileWriter_ad1d359d953b88fb07bd6e9d7b593339f}

\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsyncFileWriter_aa93346051c2a85d5856a15e2b7a0f149}{
void {\bfseries write} (\hyperlink{classXorpFd}{XorpFd}, IoEventType)}
\label{classAsyncFileWriter_aa93346051c2a85d5856a15e2b7a0f149}

\item 
\hypertarget{classAsyncFileWriter_a8d5d966b88ce843152c9d0f97a5f8a44}{
void {\bfseries complete\_\-transfer} (ssize\_\-t done)}
\label{classAsyncFileWriter_a8d5d966b88ce843152c9d0f97a5f8a44}

\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classAsyncFileWriter_a57d768930435220485f4fe15b4b95ba3}{
uint32\_\-t {\bfseries \_\-coalesce}}
\label{classAsyncFileWriter_a57d768930435220485f4fe15b4b95ba3}

\item 
\hypertarget{classAsyncFileWriter_a379319ed74484ae3a9cee987dea4c430}{
struct iovec $\ast$ {\bfseries \_\-iov}}
\label{classAsyncFileWriter_a379319ed74484ae3a9cee987dea4c430}

\item 
\hypertarget{classAsyncFileWriter_ab43191d9a5da6fca495ea9fd95485d2a}{
\hyperlink{classref__ptr}{ref\_\-ptr}$<$ int $>$ {\bfseries \_\-dtoken}}
\label{classAsyncFileWriter_ab43191d9a5da6fca495ea9fd95485d2a}

\item 
\hypertarget{classAsyncFileWriter_afc8d9f46ffd82d248073c1e0514e10d0}{
list$<$ \hyperlink{classAsyncFileWriter_1_1BufferInfo}{BufferInfo} $\ast$ $>$ {\bfseries \_\-buffers}}
\label{classAsyncFileWriter_afc8d9f46ffd82d248073c1e0514e10d0}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Write asynchronously to non-\/blocking file. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classAsyncFileWriter_ae87fb8de6088f4db160512aed5014166}{
\index{AsyncFileWriter@{AsyncFileWriter}!AsyncFileWriter@{AsyncFileWriter}}
\index{AsyncFileWriter@{AsyncFileWriter}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{AsyncFileWriter}]{\setlength{\rightskip}{0pt plus 5cm}AsyncFileWriter::AsyncFileWriter (
\begin{DoxyParamCaption}
\item[{{\bf EventLoop} \&}]{e, }
\item[{{\bf XorpFd}}]{fd, }
\item[{uint32\_\-t}]{coalesce = {\ttfamily 1}, }
\item[{int}]{priority = {\ttfamily XorpTask::PRIORITY\_\-DEFAULT}}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_ae87fb8de6088f4db160512aed5014166}

\begin{DoxyParams}{Parameters}
{\em e} & \hyperlink{classEventLoop}{EventLoop} that object should associate itself with. \\
\hline
{\em fd} & a file descriptor marked as non-\/blocking to write to. \\
\hline
{\em coalesce} & \hyperlink{protocolthe-p}{the} number of buffers to coalesce for each write() system call. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\hypertarget{classAsyncFileWriter_aa764f751bb6e2915cbc8c198da4c667e}{
\index{AsyncFileWriter@{AsyncFileWriter}!add\_\-buffer@{add\_\-buffer}}
\index{add\_\-buffer@{add\_\-buffer}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{add\_\-buffer}]{\setlength{\rightskip}{0pt plus 5cm}void AsyncFileWriter::add\_\-buffer (
\begin{DoxyParamCaption}
\item[{const uint8\_\-t $\ast$}]{buffer, }
\item[{size\_\-t}]{buffer\_\-bytes, }
\item[{const {\bf Callback} \&}]{cb}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_aa764f751bb6e2915cbc8c198da4c667e}


Add an additional buffer for writing from. 

Note that \hyperlink{protocolthe-p}{the} buffer with \hyperlink{protocolthe-p}{the} data is managed by \hyperlink{protocolthe-p}{the} user.


\begin{DoxyParams}{Parameters}
{\em buffer} & pointer to buffer. \\
\hline
{\em buffer\_\-bytes} & size of buffer in bytes. \\
\hline
{\em cb} & Callback object to invoke when I/O is performed. \\
\hline
\end{DoxyParams}
\hypertarget{classAsyncFileWriter_ac6a430573083664e114875f607db959b}{
\index{AsyncFileWriter@{AsyncFileWriter}!add\_\-buffer\_\-sendto@{add\_\-buffer\_\-sendto}}
\index{add\_\-buffer\_\-sendto@{add\_\-buffer\_\-sendto}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{add\_\-buffer\_\-sendto}]{\setlength{\rightskip}{0pt plus 5cm}void AsyncFileWriter::add\_\-buffer\_\-sendto (
\begin{DoxyParamCaption}
\item[{const uint8\_\-t $\ast$}]{buffer, }
\item[{size\_\-t}]{buffer\_\-bytes, }
\item[{const {\bf IPvX} \&}]{dst\_\-addr, }
\item[{uint16\_\-t}]{dst\_\-port, }
\item[{const {\bf Callback} \&}]{cb}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_ac6a430573083664e114875f607db959b}


Add an additional buffer for writing from by using sendto(2). 

Note that sendto()-\/buffers are never coalesced with other buffers.


\begin{DoxyParams}{Parameters}
{\em buffer} & pointer to buffer. \\
\hline
{\em buffer\_\-bytes} & size of buffer in bytes. \\
\hline
{\em dst\_\-addr} & \hyperlink{protocolthe-p}{the} destination address to send \hyperlink{protocolthe-p}{the} data to. \\
\hline
{\em dst\_\-port} & \hyperlink{protocolthe-p}{the} destination port (in host order) to send \hyperlink{protocolthe-p}{the} data to. \\
\hline
{\em cb} & Callback object to invoke when I/O is performed. \\
\hline
\end{DoxyParams}
\hypertarget{classAsyncFileWriter_a9ea8e13526ddde93820d63f5aecd7ae8}{
\index{AsyncFileWriter@{AsyncFileWriter}!add\_\-buffer\_\-with\_\-offset@{add\_\-buffer\_\-with\_\-offset}}
\index{add\_\-buffer\_\-with\_\-offset@{add\_\-buffer\_\-with\_\-offset}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{add\_\-buffer\_\-with\_\-offset}]{\setlength{\rightskip}{0pt plus 5cm}void AsyncFileWriter::add\_\-buffer\_\-with\_\-offset (
\begin{DoxyParamCaption}
\item[{const uint8\_\-t $\ast$}]{buffer, }
\item[{size\_\-t}]{buffer\_\-bytes, }
\item[{size\_\-t}]{offset, }
\item[{const {\bf Callback} \&}]{cb}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_a9ea8e13526ddde93820d63f5aecd7ae8}


Add an additional buffer for writing from. 


\begin{DoxyParams}{Parameters}
{\em buffer} & pointer to buffer. \\
\hline
{\em buffer\_\-bytes} & size of buffer in bytes. \\
\hline
{\em offset} & \hyperlink{protocolthe-p}{the} starting point to write from in \hyperlink{protocolthe-p}{the} buffer. \\
\hline
{\em cb} & Callback object to invoke when I/O is performed. \\
\hline
\end{DoxyParams}
\hypertarget{classAsyncFileWriter_a399fe1214b7c5af7c0b327ee0053f524}{
\index{AsyncFileWriter@{AsyncFileWriter}!add\_\-data@{add\_\-data}}
\index{add\_\-data@{add\_\-data}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{add\_\-data}]{\setlength{\rightskip}{0pt plus 5cm}void AsyncFileWriter::add\_\-data (
\begin{DoxyParamCaption}
\item[{const vector$<$ uint8\_\-t $>$ \&}]{data, }
\item[{const {\bf Callback} \&}]{cb}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_a399fe1214b7c5af7c0b327ee0053f524}


Add additional data for writing from. 

Note that \hyperlink{protocolthe-p}{the} data is stored to write is stored internally by \hyperlink{classAsyncFileWriter}{AsyncFileWriter}.


\begin{DoxyParams}{Parameters}
{\em data} & \hyperlink{protocolthe-p}{the} data to write. \\
\hline
{\em cb} & Callback object to invoke when I/O is performed. \\
\hline
\end{DoxyParams}
\hypertarget{classAsyncFileWriter_ad478c70c687f2d72403ff7cca9ea901d}{
\index{AsyncFileWriter@{AsyncFileWriter}!add\_\-data\_\-sendto@{add\_\-data\_\-sendto}}
\index{add\_\-data\_\-sendto@{add\_\-data\_\-sendto}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{add\_\-data\_\-sendto}]{\setlength{\rightskip}{0pt plus 5cm}void AsyncFileWriter::add\_\-data\_\-sendto (
\begin{DoxyParamCaption}
\item[{const vector$<$ uint8\_\-t $>$ \&}]{data, }
\item[{const {\bf IPvX} \&}]{dst\_\-addr, }
\item[{uint16\_\-t}]{dst\_\-port, }
\item[{const {\bf Callback} \&}]{cb}
\end{DoxyParamCaption}
)}}
\label{classAsyncFileWriter_ad478c70c687f2d72403ff7cca9ea901d}


Add additional data for writing from by using sendto(2). 

Note that \hyperlink{protocolthe-p}{the} data is stored to write is stored internally by \hyperlink{classAsyncFileWriter}{AsyncFileWriter}. Note that sendto()-\/buffers are never coalesced with other buffers.


\begin{DoxyParams}{Parameters}
{\em data} & \hyperlink{protocolthe-p}{the} data to send. \\
\hline
{\em dst\_\-addr} & \hyperlink{protocolthe-p}{the} destination address to send \hyperlink{protocolthe-p}{the} data to. \\
\hline
{\em dst\_\-port} & \hyperlink{protocolthe-p}{the} destination port (in host order) to send \hyperlink{protocolthe-p}{the} data to. \\
\hline
{\em cb} & Callback object to invoke when I/O is performed. \\
\hline
\end{DoxyParams}
\hypertarget{classAsyncFileWriter_ae3fb9be3ef862457a14fda48b58cea7b}{
\index{AsyncFileWriter@{AsyncFileWriter}!buffers\_\-remaining@{buffers\_\-remaining}}
\index{buffers\_\-remaining@{buffers\_\-remaining}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{buffers\_\-remaining}]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t AsyncFileWriter::buffers\_\-remaining (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline, virtual\mbox{]}}}}
\label{classAsyncFileWriter_ae3fb9be3ef862457a14fda48b58cea7b}
\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} number of buffers available. 
\end{DoxyReturn}


Implements \hyperlink{classAsyncFileOperator_a3fc1507061761564f4451d62cdb374a8}{AsyncFileOperator}.

\hypertarget{classAsyncFileWriter_ab6f927fca413e15ac677743499ac0d5e}{
\index{AsyncFileWriter@{AsyncFileWriter}!start@{start}}
\index{start@{start}!AsyncFileWriter@{AsyncFileWriter}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}bool AsyncFileWriter::start (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classAsyncFileWriter_ab6f927fca413e15ac677743499ac0d5e}


Start asynchronous operation. 

\begin{DoxyReturn}{Returns}
true on success, false if no buffers are available. 
\end{DoxyReturn}


Implements \hyperlink{classAsyncFileOperator_a3778390e8288097d3569833418d0728b}{AsyncFileOperator}.



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