\hypertarget{buffer__iocp_8c}{\section{opal/mca/event/libevent2013/libevent/buffer\+\_\+iocp.c File Reference}
\label{buffer__iocp_8c}\index{opal/mca/event/libevent2013/libevent/buffer\+\_\+iocp.\+c@{opal/mca/event/libevent2013/libevent/buffer\+\_\+iocp.\+c}}
}


This module implements overlapped read and write functions for evbuffer objects on Windows.  


{\ttfamily \#include \char`\"{}event2/buffer.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}event2/buffer\+\_\+compat.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}event2/util.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}event2/thread.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}event2/event-\/config.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}util-\/internal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}evthread-\/internal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}evbuffer-\/internal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}iocp-\/internal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}mm-\/internal.\+h\char`\"{}}\\*
{\ttfamily \#include $<$winsock2.\+h$>$}\\*
{\ttfamily \#include $<$windows.\+h$>$}\\*
{\ttfamily \#include $<$stdio.\+h$>$}\\*
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structevbuffer__overlapped}{evbuffer\+\_\+overlapped}
\begin{DoxyCompactList}\small\item\em An evbuffer that can handle overlapped I\+O. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{buffer__iocp_8c_a6ccfc8e6c4a3c3e1b42d0d0ff5d507fe}{\#define {\bfseries M\+A\+X\+\_\+\+W\+S\+A\+B\+U\+F\+S}~16}\label{buffer__iocp_8c_a6ccfc8e6c4a3c3e1b42d0d0ff5d507fe}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static struct \hyperlink{structevbuffer__overlapped}{evbuffer\+\_\+overlapped} $\ast$ \hyperlink{buffer__iocp_8c_a8dd2be68f458ec19688c48bf2720cc19}{upcast\+\_\+evbuffer} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Given an evbuffer, return the correponding evbuffer structure, or N\+U\+L\+L if the evbuffer isn't overlapped. \end{DoxyCompactList}\item 
static void \hyperlink{buffer__iocp_8c_abd3499e3a8f974c5116ffac6aec8a211}{pin\+\_\+release} (struct \hyperlink{structevbuffer__overlapped}{evbuffer\+\_\+overlapped} $\ast$eo, unsigned flag)
\begin{DoxyCompactList}\small\item\em Unpin all the chains noted as pinned in 'eo'. \end{DoxyCompactList}\item 
\hypertarget{buffer__iocp_8c_ade3b26966f9603f38227f5bd0cb694d4}{void \hyperlink{buffer__iocp_8c_ade3b26966f9603f38227f5bd0cb694d4}{evbuffer\+\_\+commit\+\_\+read} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$evbuf, ev\+\_\+ssize\+\_\+t n\+Bytes)}\label{buffer__iocp_8c_ade3b26966f9603f38227f5bd0cb694d4}

\begin{DoxyCompactList}\small\item\em X\+X\+X document. \end{DoxyCompactList}\item 
\hypertarget{buffer__iocp_8c_ac2116176c43b9c594cf1c05bfb35562b}{void {\bfseries evbuffer\+\_\+commit\+\_\+write} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$evbuf, ev\+\_\+ssize\+\_\+t n\+Bytes)}\label{buffer__iocp_8c_ac2116176c43b9c594cf1c05bfb35562b}

\item 
struct \hyperlink{structevbuffer}{evbuffer} $\ast$ \hyperlink{buffer__iocp_8c_a14037a8a368373cd65f37e9c3bc08e71}{evbuffer\+\_\+overlapped\+\_\+new} (\hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} fd)
\begin{DoxyCompactList}\small\item\em Allocate and return a new evbuffer that supports overlapped I\+O on a given socket. \end{DoxyCompactList}\item 
int \hyperlink{buffer__iocp_8c_aca3437ff47cafbaa6917899a1a2a9b85}{evbuffer\+\_\+launch\+\_\+write} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, ev\+\_\+ssize\+\_\+t at\+\_\+most, struct \hyperlink{structevent__overlapped}{event\+\_\+overlapped} $\ast$ol)
\begin{DoxyCompactList}\small\item\em Start writing data from the start of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer__iocp_8c_a10b95d3f897e473712d0c567fa0f44b3}{evbuffer\+\_\+launch\+\_\+read} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, size\+\_\+t at\+\_\+most, struct \hyperlink{structevent__overlapped}{event\+\_\+overlapped} $\ast$ol)
\begin{DoxyCompactList}\small\item\em Start reading data onto the end of an overlapped evbuffer. \end{DoxyCompactList}\item 
\hypertarget{buffer__iocp_8c_a3176515d01bc77525e60d5fd70205282}{\hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} \hyperlink{buffer__iocp_8c_a3176515d01bc77525e60d5fd70205282}{\+\_\+evbuffer\+\_\+overlapped\+\_\+get\+\_\+fd} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)}\label{buffer__iocp_8c_a3176515d01bc77525e60d5fd70205282}

\begin{DoxyCompactList}\small\item\em X\+X\+X\+X Document (nickm) \end{DoxyCompactList}\item 
\hypertarget{buffer__iocp_8c_a2530839e215dc5d1b1d42a552231eb9a}{void {\bfseries \+\_\+evbuffer\+\_\+overlapped\+\_\+set\+\_\+fd} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, \hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} fd)}\label{buffer__iocp_8c_a2530839e215dc5d1b1d42a552231eb9a}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
This module implements overlapped read and write functions for evbuffer objects on Windows. 



\subsection{Function Documentation}
\hypertarget{buffer__iocp_8c_a10b95d3f897e473712d0c567fa0f44b3}{\index{buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}!evbuffer\+\_\+launch\+\_\+read@{evbuffer\+\_\+launch\+\_\+read}}
\index{evbuffer\+\_\+launch\+\_\+read@{evbuffer\+\_\+launch\+\_\+read}!buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}}
\subsubsection[{evbuffer\+\_\+launch\+\_\+read}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+launch\+\_\+read (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{size\+\_\+t}]{n, }
\item[{struct {\bf event\+\_\+overlapped} $\ast$}]{ol}
\end{DoxyParamCaption}
)}}\label{buffer__iocp_8c_a10b95d3f897e473712d0c567fa0f44b3}


Start reading data onto the end of an overlapped evbuffer. 

An evbuffer can only have one read pending at a time. While the read is in progress, no other data may be added to the end of the buffer. The buffer must be created with event\+\_\+overlapped\+\_\+init(). \hyperlink{buffer__iocp_8c_ade3b26966f9603f38227f5bd0cb694d4}{evbuffer\+\_\+commit\+\_\+read()} must be called in the completion callback.


\begin{DoxyParams}{Parameters}
{\em buf} & The buffer to read onto \\
\hline
{\em n} & The number of bytes to try to read. \\
\hline
{\em ol} & Overlapped object with associated completion callback. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on error. 
\end{DoxyReturn}


References evbuffer\+\_\+free(), evbuffer\+\_\+freeze(), evbuffer\+\_\+unfreeze(), evbuffer\+\_\+overlapped\+::fd, evbuffer\+\_\+overlapped\+::first\+\_\+pinned, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+end, evbuffer\+\_\+overlapped\+::n\+\_\+buffers, evbuffer\+\_\+chain\+::next, pin\+\_\+release(), evbuffer\+\_\+overlapped\+::read\+\_\+in\+\_\+progress, and upcast\+\_\+evbuffer().

\hypertarget{buffer__iocp_8c_aca3437ff47cafbaa6917899a1a2a9b85}{\index{buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}!evbuffer\+\_\+launch\+\_\+write@{evbuffer\+\_\+launch\+\_\+write}}
\index{evbuffer\+\_\+launch\+\_\+write@{evbuffer\+\_\+launch\+\_\+write}!buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}}
\subsubsection[{evbuffer\+\_\+launch\+\_\+write}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+launch\+\_\+write (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{ev\+\_\+ssize\+\_\+t}]{n, }
\item[{struct {\bf event\+\_\+overlapped} $\ast$}]{ol}
\end{DoxyParamCaption}
)}}\label{buffer__iocp_8c_aca3437ff47cafbaa6917899a1a2a9b85}


Start writing data from the start of an evbuffer. 

An evbuffer can only have one write pending at a time. While the write is in progress, no other data may be removed from the front of the buffer. The buffer must be created with event\+\_\+overlapped\+\_\+init(). evbuffer\+\_\+commit\+\_\+write() must be called in the completion callback.


\begin{DoxyParams}{Parameters}
{\em buf} & The buffer to read onto \\
\hline
{\em n} & The number of bytes to try to read. \\
\hline
{\em ol} & Overlapped object with associated completion callback. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on error. 
\end{DoxyReturn}


References evbuffer\+\_\+free(), evbuffer\+\_\+freeze(), evbuffer\+\_\+unfreeze(), evbuffer\+\_\+overlapped\+::fd, evbuffer\+::first, evbuffer\+\_\+overlapped\+::first\+\_\+pinned, evbuffer\+::freeze\+\_\+start, evbuffer\+\_\+overlapped\+::n\+\_\+buffers, evbuffer\+\_\+chain\+::next, pin\+\_\+release(), evbuffer\+\_\+overlapped\+::read\+\_\+in\+\_\+progress, evbuffer\+::total\+\_\+len, and upcast\+\_\+evbuffer().

\hypertarget{buffer__iocp_8c_a14037a8a368373cd65f37e9c3bc08e71}{\index{buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}!evbuffer\+\_\+overlapped\+\_\+new@{evbuffer\+\_\+overlapped\+\_\+new}}
\index{evbuffer\+\_\+overlapped\+\_\+new@{evbuffer\+\_\+overlapped\+\_\+new}!buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}}
\subsubsection[{evbuffer\+\_\+overlapped\+\_\+new}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer}$\ast$ evbuffer\+\_\+overlapped\+\_\+new (
\begin{DoxyParamCaption}
\item[{{\bf evutil\+\_\+socket\+\_\+t}}]{fd}
\end{DoxyParamCaption}
)}}\label{buffer__iocp_8c_a14037a8a368373cd65f37e9c3bc08e71}


Allocate and return a new evbuffer that supports overlapped I\+O on a given socket. 

The socket must be associated with an I\+O completion port using event\+\_\+iocp\+\_\+port\+\_\+associate. 

References evbuffer\+\_\+overlapped\+::fd, evbuffer\+::first, evbuffer\+::last\+\_\+with\+\_\+datap, and evbuffer\+::refcnt.

\hypertarget{buffer__iocp_8c_abd3499e3a8f974c5116ffac6aec8a211}{\index{buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}!pin\+\_\+release@{pin\+\_\+release}}
\index{pin\+\_\+release@{pin\+\_\+release}!buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}}
\subsubsection[{pin\+\_\+release}]{\setlength{\rightskip}{0pt plus 5cm}static void pin\+\_\+release (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer\+\_\+overlapped} $\ast$}]{eo, }
\item[{unsigned}]{flag}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{buffer__iocp_8c_abd3499e3a8f974c5116ffac6aec8a211}


Unpin all the chains noted as pinned in 'eo'. 



References evbuffer\+\_\+overlapped\+::first\+\_\+pinned, evbuffer\+\_\+overlapped\+::n\+\_\+buffers, and evbuffer\+\_\+chain\+::next.



Referenced by evbuffer\+\_\+commit\+\_\+read(), evbuffer\+\_\+launch\+\_\+read(), and evbuffer\+\_\+launch\+\_\+write().

\hypertarget{buffer__iocp_8c_a8dd2be68f458ec19688c48bf2720cc19}{\index{buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}!upcast\+\_\+evbuffer@{upcast\+\_\+evbuffer}}
\index{upcast\+\_\+evbuffer@{upcast\+\_\+evbuffer}!buffer\+\_\+iocp.\+c@{buffer\+\_\+iocp.\+c}}
\subsubsection[{upcast\+\_\+evbuffer}]{\setlength{\rightskip}{0pt plus 5cm}static struct {\bf evbuffer\+\_\+overlapped}$\ast$ upcast\+\_\+evbuffer (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{buffer__iocp_8c_a8dd2be68f458ec19688c48bf2720cc19}


Given an evbuffer, return the correponding evbuffer structure, or N\+U\+L\+L if the evbuffer isn't overlapped. 



Referenced by \+\_\+evbuffer\+\_\+overlapped\+\_\+get\+\_\+fd(), evbuffer\+\_\+commit\+\_\+read(), evbuffer\+\_\+launch\+\_\+read(), and evbuffer\+\_\+launch\+\_\+write().

