Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 759

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{ost::Socket\-Service Class Reference}
\label{classost_1_1_socket_service}\index{ost::SocketService@{ost::SocketService}}
The {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} is a thread pool object that is meant to service attached socket {\bf ports.Thread}{\rm (p.\,\pageref{namespaceost_1a3b6738f6f759fcb52b544a4787cbb2})} pool service object for socket ports.  


{\tt \#include $<$socketport.h$>$}

Inheritance diagram for ost::Socket\-Service::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2cm]{classost_1_1_socket_service}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
void {\bf update} (unsigned char flag=0xff)
\begin{CompactList}\small\item\em Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports. \item\end{CompactList}\item 
{\bf Socket\-Service} (int pri=0, size\_\-t stack=0, const char $\ast$id=NULL)
\begin{CompactList}\small\item\em Create a service thread for attaching socket ports. \item\end{CompactList}\item 
virtual {\bf $\sim$Socket\-Service} ()
\begin{CompactList}\small\item\em Terminate the thread pool and eliminate any attached socket ports. \item\end{CompactList}\item 
int {\bf get\-Count} (void) const 
\begin{CompactList}\small\item\em Get current reference count. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf on\-Update} (unsigned char buf)
\begin{CompactList}\small\item\em Handles all requests other than \char`\"{}termination\char`\"{}. \item\end{CompactList}\item 
virtual void {\bf on\-Event} (void)
\begin{CompactList}\small\item\em Called once each time the service thread is rescheduled. \item\end{CompactList}\item 
virtual void {\bf on\-Callback} ({\bf Socket\-Port} $\ast$port)
\begin{CompactList}\small\item\em Called for each port that is being processed in response to an event. \item\end{CompactList}\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf Socket\-Port}
\end{CompactItemize}


\subsection{Detailed Description}
The {\bf Socket\-Service}{\rm (p.\,\pageref{classost_1_1_socket_service})} is a thread pool object that is meant to service attached socket {\bf ports.Thread}{\rm (p.\,\pageref{namespaceost_1a3b6738f6f759fcb52b544a4787cbb2})} pool service object for socket ports. 

Multiple pool objects may be created and multiple socket ports may be attached to the same thread of execution. This allows one to balance threads and sockets they service rather than either using a single thread for all connections or a seperate thread for each connection. Features can be added through supported virtual methods.

\begin{Desc}
\item[Author:]David Sugar $<${\tt dyfet@ostel.com}$>$ \end{Desc}
\begin{Desc}
\item[Examples: ]\par


{\bf tcpservice.cpp}.\end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::SocketService@{ost::Socket\-Service}!SocketService@{SocketService}}
\index{SocketService@{SocketService}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Socket\-Service::Socket\-Service (int {\em pri} = {\tt 0}, size\_\-t {\em stack} = {\tt 0}, const char $\ast$ {\em id} = {\tt NULL})}\label{classost_1_1_socket_service_3a312fb56c00a0472fc0701898dc3ece}


Create a service thread for attaching socket ports. 

The thread begins execution with the first attached socket.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em pri}]of this thread to run under. \item[{\em stack}]stack size. \item[{\em id}]thread ID. \end{description}
\end{Desc}
\index{ost::SocketService@{ost::Socket\-Service}!~SocketService@{$\sim$SocketService}}
\index{~SocketService@{$\sim$SocketService}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::Socket\-Service::$\sim$Socket\-Service ()\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_socket_service_9a370cf56f889b416847cc8759a9b49c}


Terminate the thread pool and eliminate any attached socket ports. 



\subsection{Member Function Documentation}
\index{ost::SocketService@{ost::Socket\-Service}!getCount@{getCount}}
\index{getCount@{getCount}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int ost::Socket\-Service::get\-Count (void) const\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_socket_service_870e3205e044e2862b9f17739ba8172c}


Get current reference count. 

This can be used when selecting the least used service handler from a pool.

\begin{Desc}
\item[Returns:]count of active ports. \end{Desc}
\index{ost::SocketService@{ost::Socket\-Service}!onCallback@{onCallback}}
\index{onCallback@{onCallback}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Service::on\-Callback ({\bf Socket\-Port} $\ast$ {\em port})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classost_1_1_socket_service_3a399c80d80b5d672dd01e273673dd33}


Called for each port that is being processed in response to an event. 

This can be used to add additional notification options during callback in combination with {\bf update()}{\rm (p.\,\pageref{classost_1_1_socket_service_b43b58d6e7d8ce34e2906f3e79a25e69})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port}]{\bf Socket\-Port}{\rm (p.\,\pageref{classost_1_1_socket_port})} who's callback events are being evaluated. \end{description}
\end{Desc}
\index{ost::SocketService@{ost::Socket\-Service}!onEvent@{onEvent}}
\index{onEvent@{onEvent}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Service::on\-Event (void)\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classost_1_1_socket_service_206f1b02739f322cb38a33b0e409a32f}


Called once each time the service thread is rescheduled. 

This is called after the mutex is locked and can be used to slip in additional processing. \index{ost::SocketService@{ost::Socket\-Service}!onUpdate@{onUpdate}}
\index{onUpdate@{onUpdate}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void ost::Socket\-Service::on\-Update (unsigned char {\em buf})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classost_1_1_socket_service_4914e4f6bfbab8c233244b7b44e52c86}


Handles all requests other than \char`\"{}termination\char`\"{}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em buf}]request id as posted from {\bf update()}{\rm (p.\,\pageref{classost_1_1_socket_service_b43b58d6e7d8ce34e2906f3e79a25e69})}. \end{description}
\end{Desc}
\index{ost::SocketService@{ost::Socket\-Service}!update@{update}}
\index{update@{update}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Socket\-Service::update (unsigned char {\em flag} = {\tt 0xff})}\label{classost_1_1_socket_service_b43b58d6e7d8ce34e2906f3e79a25e69}


Notify service thread that a port has been added or removed, or a timer changed, so that a new schedule can be computed for expiring attached ports. 

A \char`\"{}0\char`\"{} is used to terminate the service thread, and additional values can be specified which will be \char`\"{}caught\char`\"{} in the {\bf on\-Update()}{\rm (p.\,\pageref{classost_1_1_socket_service_4914e4f6bfbab8c233244b7b44e52c86})} handler.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em flag}]update flag value. \end{description}
\end{Desc}


\subsection{Friends And Related Function Documentation}
\index{ost::SocketService@{ost::Socket\-Service}!SocketPort@{SocketPort}}
\index{SocketPort@{SocketPort}!ost::SocketService@{ost::Socket\-Service}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}friend class {\bf Socket\-Port}\hspace{0.3cm}{\tt  [friend]}}\label{classost_1_1_socket_service_9884a27b35e263e19e4acf2cb06c4071}




The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
{\bf socketport.h}\end{CompactItemize}