\section{thread.h File Reference} \label{thread_8h}\index{thread.h@{thread.h}} Synchronization and threading services. {\tt \#include $<$cc++/config.h$>$}\par {\tt \#include $<$ctime$>$}\par {\tt \#include $<$pthread.h$>$}\par {\tt \#include $<$time.h$>$}\par {\tt \#include $<$signal.h$>$}\par {\tt \#include $<$unistd.h$>$}\par \subsection*{Namespaces} \begin{CompactItemize} \item namespace {\bf ost} \end{CompactItemize} \subsection*{Classes} \begin{CompactItemize} \item class {\bf ost::Mutex} \begin{CompactList}\small\item\em The {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})} class is used to protect a section of code so that at any given time only a single thread can perform the protected operation.Mutex lock for protected access. \item\end{CompactList}\item class {\bf ost::Mutex\-Lock} \begin{CompactList}\small\item\em The {\bf Mutex\-Lock}{\rm (p.\,\pageref{classost_1_1_mutex_lock})} class is used to protect a section of code so that at any given time only a single thread can perform the protected operation.Mutex automatic locker for protected access. \item\end{CompactList}\item class {\bf ost::Thread\-Lock} \begin{CompactList}\small\item\em The {\bf Thread\-Lock}{\rm (p.\,\pageref{classost_1_1_thread_lock})} class impliments a thread rwlock for optimal reader performance on systems which have rwlock support, and reverts to a simple mutex for those that do not.Posix rwlock extension for protected access. \item\end{CompactList}\item class {\bf ost::Read\-Lock} \begin{CompactList}\small\item\em The {\bf Read\-Lock}{\rm (p.\,\pageref{classost_1_1_read_lock})} class is used to protect a section of code through a {\bf Thread\-Lock}{\rm (p.\,\pageref{classost_1_1_thread_lock})} for \char`\"{}read\char`\"{} access to the member function.Read mode automatic locker for protected access. \item\end{CompactList}\item class {\bf ost::Write\-Lock} \begin{CompactList}\small\item\em The {\bf Write\-Lock}{\rm (p.\,\pageref{classost_1_1_write_lock})} class is used to protect a section of code through a {\bf Thread\-Lock}{\rm (p.\,\pageref{classost_1_1_thread_lock})} for \char`\"{}write\char`\"{} access to the member function.Read mode automatic locker for protected access. \item\end{CompactList}\item class {\bf ost::Mutex\-Counter} \begin{CompactList}\small\item\em The {\bf Mutex}{\rm (p.\,\pageref{classost_1_1_mutex})} {\bf Counter}{\rm (p.\,\pageref{classost_1_1_counter})} is a counter variable which can safely be incremented or decremented by multiple {\bf threads.Thread}{\rm (p.\,\pageref{namespaceost_1a3b6738f6f759fcb52b544a4787cbb2})} protected integer counter. \item\end{CompactList}\item class {\bf ost::Atomic\-Counter} \begin{CompactList}\small\item\em The {\bf Atomic\-Counter}{\rm (p.\,\pageref{classost_1_1_atomic_counter})} class offers thread-safe manipulation of an integer counter.atomic counter operation. \item\end{CompactList}\item class {\bf ost::Conditional} \begin{CompactList}\small\item\em A conditional variable synchcronization object for one to one and one to many signal and control events between processes.conditional. \item\end{CompactList}\item class {\bf ost::Semaphore} \begin{CompactList}\small\item\em A semaphore is generally used as a synchronization object between multiple threads or to protect a limited and finite resource such as a memory or thread pool.Semaphore counter for thread synchronization. \item\end{CompactList}\item class {\bf ost::Semaphore\-Lock} \begin{CompactList}\small\item\em The {\bf Semaphore\-Lock}{\rm (p.\,\pageref{classost_1_1_semaphore_lock})} class is used to protect a section of code through a semaphore so that only x instances of the member function may execute concurrently.Semaphore automatic locker for protected access. \item\end{CompactList}\item class {\bf ost::Event} \begin{CompactList}\small\item\em The {\bf Event}{\rm (p.\,\pageref{classost_1_1_event})} class implements a feature originally found in the WIN32 API; event {\bf notification.Thread}{\rm (p.\,\pageref{namespaceost_1a3b6738f6f759fcb52b544a4787cbb2})} synchornization on event notification. \item\end{CompactList}\item class {\bf ost::Thread} \begin{CompactList}\small\item\em Every thread of execution in an application is created by instantiating an object of a class derived from the {\bf Thread}{\rm (p.\,\pageref{classost_1_1_thread})} class.base class used to derive all threads of execution. \item\end{CompactList}\item class {\bf ost::Cancellation} \begin{CompactList}\small\item\em A class to automatically set the thread cancellation mode of a member function.Automatic cancellation mode setting. \item\end{CompactList}\item class {\bf ost::Posix\-Thread} \item class {\bf ost::Thread\-Key} \begin{CompactList}\small\item\em This class allows the creation of a thread context unique \char`\"{}pointer\char`\"{} that can be set and retrieved and can be used to create thread specific data areas for implementing \char`\"{}thread safe\char`\"{} library routines.container for thread specific data storage. \item\end{CompactList}\item class {\bf ost::Timer\-Port} \begin{CompactList}\small\item\em Timer ports are used to provide synchronized timing events when managed under a \char`\"{}service thread\char`\"{} such as Socket\-Service.synchronized millisecond timing for service threads. \item\end{CompactList}\item class {\bf ost::Sys\-Time} \begin{CompactList}\small\item\em This class is used to access non-reentrant date and time functions in the standard C {\bf library.Thread}{\rm (p.\,\pageref{namespaceost_1a3b6738f6f759fcb52b544a4787cbb2})} safe date and time functions. \item\end{CompactList}\end{CompactItemize} \subsection*{Defines} \begin{CompactItemize} \item \#define {\bf CCXX\_\-POSIX} \item \#define {\bf TIMEOUT\_\-INF}~$\sim$(({\bf timeout\_\-t}) 0) \item \#define {\bf ENTER\_\-CRITICAL}~enter\-Mutex(); \item \#define {\bf LEAVE\_\-CRITICAL}~leave\-Mutex(); \item \#define {\bf ENTER\_\-DEFERRED}~set\-Cancel(cancel\-Deferred); \item \#define {\bf LEAVE\_\-DEFERRED}~set\-Cancel(cancel\-Immediate); \item \#define {\bf psleep}(x)~(sleep)(x) \end{CompactItemize} \subsection*{Typedefs} \begin{CompactItemize} \item typedef pthread\_\-t {\bf cctid\_\-t} \item typedef unsigned long {\bf timeout\_\-t} \item typedef int {\bf ost::signo\_\-t} \end{CompactItemize} \subsection*{Functions} \begin{CompactItemize} \item timespec $\ast$ {\bf ost::get\-Timeout} (struct timespec $\ast$spec, {\bf timeout\_\-t} timeout) \item void {\bf ost::wait} ({\bf signo\_\-t} signo) \item {\bf Thread} $\ast$ {\bf ost::get\-Thread} (void) \item tm $\ast$ {\bf ost::localtime\_\-r} (const time\_\-t $\ast$t, struct tm $\ast$b) \item char $\ast$ {\bf ost::ctime\_\-r} (const time\_\-t $\ast$t, char $\ast$buf) \item tm $\ast$ {\bf ost::gmtime\_\-r} (const time\_\-t $\ast$t, struct tm $\ast$b) \item char $\ast$ {\bf ost::asctime\_\-r} (const struct tm $\ast$tm, char $\ast$b) \end{CompactItemize} \subsection*{Variables} \begin{CompactItemize} \item \_\-\_\-EXPORT {\bf ost::Thread} \item \_\-\_\-EXPORT {\bf ost::Thread\-Key} \item \_\-\_\-EXPORT {\bf ost::Conditional} \item \_\-\_\-EXPORT {\bf ost::Event} \end{CompactItemize} \subsection{Detailed Description} Synchronization and threading services. \subsection{Define Documentation} \index{thread.h@{thread.h}!CCXX_POSIX@{CCXX\_\-POSIX}} \index{CCXX_POSIX@{CCXX\_\-POSIX}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define CCXX\_\-POSIX}\label{thread_8h_9fc514088fa3739a1300ce30ca6585d5} \index{thread.h@{thread.h}!ENTER_CRITICAL@{ENTER\_\-CRITICAL}} \index{ENTER_CRITICAL@{ENTER\_\-CRITICAL}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ENTER\_\-CRITICAL~enter\-Mutex();}\label{thread_8h_9d5589bc014dcec626ff198d5c9370cd} \index{thread.h@{thread.h}!ENTER_DEFERRED@{ENTER\_\-DEFERRED}} \index{ENTER_DEFERRED@{ENTER\_\-DEFERRED}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ENTER\_\-DEFERRED~set\-Cancel(cancel\-Deferred);}\label{thread_8h_61438c8055883ef92ffb09c68f70f049} \index{thread.h@{thread.h}!LEAVE_CRITICAL@{LEAVE\_\-CRITICAL}} \index{LEAVE_CRITICAL@{LEAVE\_\-CRITICAL}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define LEAVE\_\-CRITICAL~leave\-Mutex();}\label{thread_8h_f1b76aeceb2370c5fcedee46f9cd3d09} \index{thread.h@{thread.h}!LEAVE_DEFERRED@{LEAVE\_\-DEFERRED}} \index{LEAVE_DEFERRED@{LEAVE\_\-DEFERRED}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define LEAVE\_\-DEFERRED~set\-Cancel(cancel\-Immediate);}\label{thread_8h_c6e53238dd0519d7c7117b2b40d4312b} \index{thread.h@{thread.h}!psleep@{psleep}} \index{psleep@{psleep}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define psleep(x)~(sleep)(x)}\label{thread_8h_5e09ab8cba99b274fd420bd76f39b205} \index{thread.h@{thread.h}!TIMEOUT_INF@{TIMEOUT\_\-INF}} \index{TIMEOUT_INF@{TIMEOUT\_\-INF}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define TIMEOUT\_\-INF~$\sim$(({\bf timeout\_\-t}) 0)}\label{thread_8h_74f2d4c747bce0b8f7f7c1f48e651876} \subsection{Typedef Documentation} \index{thread.h@{thread.h}!cctid_t@{cctid\_\-t}} \index{cctid_t@{cctid\_\-t}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}typedef pthread\_\-t {\bf cctid\_\-t}}\label{thread_8h_3f0d0226a694bf1e508e1b1c758e6ae6} \index{thread.h@{thread.h}!timeout_t@{timeout\_\-t}} \index{timeout_t@{timeout\_\-t}!thread.h@{thread.h}} \subsubsection{\setlength{\rightskip}{0pt plus 5cm}typedef unsigned long {\bf timeout\_\-t}}\label{thread_8h_f412159e5cef839836a5e7b19ee75d1c}