\hypertarget{class_s_c_i_run_1_1_mailbox}{\section{Mailbox$<$ Item $>$ Class Template Reference}
\label{class_s_c_i_run_1_1_mailbox}\index{Mailbox$<$ Item $>$@{Mailbox$<$ Item $>$}}
}


{\ttfamily \#include $<$Mailbox.\-h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_s_c_i_run_1_1_mailbox_a0ee373b2d1102f1d5c06b194be76d59f}{Mailbox} (const char $\ast$\hyperlink{_boost_graph_example_tests_8cc_a8ad72759d07f18eaf8f6690e5dfb747c}{name}, int \hyperlink{class_s_c_i_run_1_1_mailbox_ab8e4e3e2a7bf18888b71bdf9dda0770b}{size})
\item 
\hyperlink{class_s_c_i_run_1_1_mailbox_acf9eacd183f34cd76d8592cf0f2a9ba3}{$\sim$\-Mailbox} ()
\item 
void \hyperlink{class_s_c_i_run_1_1_mailbox_a36e4271f881fb7dabcebdcd6b3d4f604}{send} (const Item \&\hyperlink{_piecewise_interp_8h_ae550ae40597e95f2cf7455585d9db07c}{msg})
\item 
bool \hyperlink{class_s_c_i_run_1_1_mailbox_afeaf8486ee12f6b4c3e84256077054ff}{try\-Send} (const Item \&\hyperlink{_piecewise_interp_8h_ae550ae40597e95f2cf7455585d9db07c}{msg})
\item 
bool \hyperlink{class_s_c_i_run_1_1_mailbox_a550235e1ff3f53be1bb88005d6570be6}{send\-If\-Not\-Sent\-Last} (const Item \&\hyperlink{_piecewise_interp_8h_ae550ae40597e95f2cf7455585d9db07c}{msg}, bool($\ast$checker)(const Item \&a, const Item \&b))
\item 
Item \hyperlink{class_s_c_i_run_1_1_mailbox_a4316a920203e537c02ed2838e25461e1}{receive} ()
\item 
bool \hyperlink{class_s_c_i_run_1_1_mailbox_a2c06bd70bf329917c39736ad5b2b6682}{try\-Receive} (Item \&item)
\item 
int \hyperlink{class_s_c_i_run_1_1_mailbox_ab8e4e3e2a7bf18888b71bdf9dda0770b}{size} () const 
\item 
int \hyperlink{class_s_c_i_run_1_1_mailbox_ab59225ec172524007486f574a53f4f7d}{num\-Items} () const 
\begin{DoxyCompactList}\small\item\em Return the number of items currently in the queue. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_s_c_i_run_1_1_mailbox_a0ee373b2d1102f1d5c06b194be76d59f}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!Mailbox@{Mailbox}}
\index{Mailbox@{Mailbox}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{Mailbox}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Mailbox} (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{name, }
\item[{int}]{size}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_a0ee373b2d1102f1d5c06b194be76d59f}
Create a mailbox with a maximum queue size of {\itshape size} items. If size is zero, then the mailbox will use {\itshape rendevous semantics}, where a sender will block until a reciever is waiting for the item. The item will be handed off synchronously. {\itshape name} should be a static string which describes the primitive for debugging purposes. \hypertarget{class_s_c_i_run_1_1_mailbox_acf9eacd183f34cd76d8592cf0f2a9ba3}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!$\sim$\-Mailbox@{$\sim$\-Mailbox}}
\index{$\sim$\-Mailbox@{$\sim$\-Mailbox}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{$\sim$\-Mailbox}]{\setlength{\rightskip}{0pt plus 5cm}$\sim${\bf Mailbox} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_acf9eacd183f34cd76d8592cf0f2a9ba3}
Destroy the mailbox. All items in the queue are silently dropped. 

\subsection{Member Function Documentation}
\hypertarget{class_s_c_i_run_1_1_mailbox_ab59225ec172524007486f574a53f4f7d}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!num\-Items@{num\-Items}}
\index{num\-Items@{num\-Items}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{num\-Items}]{\setlength{\rightskip}{0pt plus 5cm}int num\-Items (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}\label{class_s_c_i_run_1_1_mailbox_ab59225ec172524007486f574a53f4f7d}


Return the number of items currently in the queue. 

\hypertarget{class_s_c_i_run_1_1_mailbox_a4316a920203e537c02ed2838e25461e1}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!receive@{receive}}
\index{receive@{receive}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{receive}]{\setlength{\rightskip}{0pt plus 5cm}Item receive (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_a4316a920203e537c02ed2838e25461e1}
Receive an item from the queue. If the queue is empty, the thread will block until another thread sends an item. Multiple threads may call {\itshape recieve} concurrently, but no guarantee is made as to which thread will recieve the next token. However, implementors should give preference to the thread that has been waiting the longest. \hypertarget{class_s_c_i_run_1_1_mailbox_a36e4271f881fb7dabcebdcd6b3d4f604}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!send@{send}}
\index{send@{send}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{send}]{\setlength{\rightskip}{0pt plus 5cm}void send (
\begin{DoxyParamCaption}
\item[{const Item \&}]{msg}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_a36e4271f881fb7dabcebdcd6b3d4f604}
Puts {\itshape msg} in the queue. If the queue is full, the thread will be blocked until there is room in the queue. Messages from the same thread will be placed in the queue in a first-\/in/first out order. Multiple threads may call {\itshape send} concurrently, and the messages will be placed in the queue in an arbitrary order. \hypertarget{class_s_c_i_run_1_1_mailbox_a550235e1ff3f53be1bb88005d6570be6}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!send\-If\-Not\-Sent\-Last@{send\-If\-Not\-Sent\-Last}}
\index{send\-If\-Not\-Sent\-Last@{send\-If\-Not\-Sent\-Last}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{send\-If\-Not\-Sent\-Last}]{\setlength{\rightskip}{0pt plus 5cm}bool send\-If\-Not\-Sent\-Last (
\begin{DoxyParamCaption}
\item[{const Item \&}]{msg, }
\item[{bool($\ast$)(const Item \&a, const Item \&b)}]{checker}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_a550235e1ff3f53be1bb88005d6570be6}
Send {\itshape msg} to the queue only if the {\itshape checker} function fails to compare the {\itshape msg} to what is already the last item there. This is useful if we want to make certain that at least one of a particular message (like a viewer resize redraw) gets put on the mailbox without spamming it. This blocks like {\itshape send} does. It returns true if {\itshape msg} was added to the queue and false if it wasn't. \hypertarget{class_s_c_i_run_1_1_mailbox_ab8e4e3e2a7bf18888b71bdf9dda0770b}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!size@{size}}
\index{size@{size}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{size}]{\setlength{\rightskip}{0pt plus 5cm}int size (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const}}\label{class_s_c_i_run_1_1_mailbox_ab8e4e3e2a7bf18888b71bdf9dda0770b}
Return the maximum size of the mailbox queue, as given in the constructor. \hypertarget{class_s_c_i_run_1_1_mailbox_a2c06bd70bf329917c39736ad5b2b6682}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!try\-Receive@{try\-Receive}}
\index{try\-Receive@{try\-Receive}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{try\-Receive}]{\setlength{\rightskip}{0pt plus 5cm}bool try\-Receive (
\begin{DoxyParamCaption}
\item[{Item \&}]{item}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_a2c06bd70bf329917c39736ad5b2b6682}
Attempt to recieve {\itshape item} from the mailbox. If the queue is empty, the thread is blocked and {\itshape try\-Recieve} will return false. Otherwise, {\itshape try\-Recieve} returns true. \hypertarget{class_s_c_i_run_1_1_mailbox_afeaf8486ee12f6b4c3e84256077054ff}{\index{S\-C\-I\-Run\-::\-Mailbox@{S\-C\-I\-Run\-::\-Mailbox}!try\-Send@{try\-Send}}
\index{try\-Send@{try\-Send}!SCIRun::Mailbox@{S\-C\-I\-Run\-::\-Mailbox}}
\subsubsection[{try\-Send}]{\setlength{\rightskip}{0pt plus 5cm}bool try\-Send (
\begin{DoxyParamCaption}
\item[{const Item \&}]{msg}
\end{DoxyParamCaption}
)}}\label{class_s_c_i_run_1_1_mailbox_afeaf8486ee12f6b4c3e84256077054ff}
Attempt to send {\itshape msg} to the queue. If the queue is full, the thread will not be blocked, and {\itshape try\-Send} will return false. Otherwise, {\itshape try\-Send} will return true. This may never complete if the reciever only uses {\itshape try\-Recieve}. 

The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
Core/\-Thread/\-Legacy/\hyperlink{_mailbox_8h}{Mailbox.\-h}\end{DoxyCompactItemize}
