\section{Basic\-Thread Class Reference}
\label{class_basic_thread}\index{BasicThread@{BasicThread}}
There are two was to use this class.  


{\tt \#include $<$Basic\-Thread.h$>$}

Inheritance diagram for Basic\-Thread:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=60pt]{class_basic_thread__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for Basic\-Thread:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=117pt]{class_basic_thread__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Basic\-Thread} ()
\item 
{\bf Basic\-Thread} ({\bf Basic\-Functor\-Base} $\ast${\bf functor})
\item 
{\bf Basic\-Thread} (void $\ast$($\ast${\bf start\-Routine})(void $\ast$))
\item 
virtual {\bf $\sim$Basic\-Thread} ()
\item 
virtual void {\bf run} ()
\begin{CompactList}\small\item\em This virtual function should be overriden by inheriting process. \item\end{CompactList}\item 
bool {\bf start} ()
\begin{CompactList}\small\item\em Starts the thread. \item\end{CompactList}\item 
void {\bf stop} ()
\begin{CompactList}\small\item\em Requests the thread stop via the shutdown variable. \item\end{CompactList}\item 
bool {\bf join} ()
\begin{CompactList}\small\item\em This causes the calling thread of execution to block until the thread of this object exits. \item\end{CompactList}\item 
bool {\bf cancel} ()
\item 
bool {\bf detach} ()
\item 
void $\ast$ {\bf get\-Data} ()
\item 
void {\bf set\-Data} (void $\ast${\bf data})
\item 
void {\bf set\-Running} (bool x)
\begin{CompactList}\small\item\em This function is not always necessary. \item\end{CompactList}\item 
bool {\bf is\-Running} ()
\item 
bool {\bf should\-Shutdown} ()
\begin{CompactList}\small\item\em This function should be called from the thread itself to determine if shutdown has been requested. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
void {\bf test\-Cancel} ()
\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
bool {\bf shutdown}
\item 
bool {\bf running}
\end{CompactItemize}
\subsection*{Private Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf on\-Exit} ()
\begin{CompactList}\small\item\em This virtual function can be overriden by inheriting classes which would like to do some extra processing on thread exit. \item\end{CompactList}\item 
virtual void {\bf on\-Entrance} ()
\begin{CompactList}\small\item\em This virtual function can be overriden by inheriting classes which would like to do some extra processing before thread startup. \item\end{CompactList}\item 
void {\bf init} ()
\begin{CompactList}\small\item\em This function does initializations common to all the constructors. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Private Member Functions}
\begin{CompactItemize}
\item 
void $\ast$ {\bf starter} (void $\ast$me)
\begin{CompactList}\small\item\em This static function should never be called directly. \item\end{CompactList}\end{CompactItemize}
\subsection*{Private Attributes}
\begin{CompactItemize}
\item 
pthread\_\-t {\bf thread}
\item 
pthread\_\-attr\_\-t {\bf attr}
\item 
{\bf Basic\-Functor\-Base} $\ast$ {\bf functor}
\item 
void $\ast$($\ast$ {\bf start\-Routine} )(void $\ast$)
\item 
void $\ast$ {\bf data}
\end{CompactItemize}


\subsection{Detailed Description}
There are two was to use this class. 

\begin{enumerate}
\item A class can inherit from Basic\-Thread and implement the the virtual {\bf run()}{\rm (p.\,\pageref{class_basic_thread_a4})} function. This alows the object to have its own thread of execution.\item A user can instantiate Basic\-Thread passing in a pointer to a void $\ast$start\-Routine(void $\ast$). When the start function of of the thread object is called the start\-Routine will be called with a new thread of execution.\end{enumerate}


The user has the ability to set a data variable which will be passed to the user function. This void $\ast$ is set to point to the Basic\-Thread object itself by default. This gives the user the ability to communicate data to the thread without using global data. 



\subsection{Constructor \& Destructor Documentation}
\index{BasicThread@{Basic\-Thread}!BasicThread@{BasicThread}}
\index{BasicThread@{BasicThread}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Basic\-Thread::Basic\-Thread ()}\label{class_basic_thread_a0}


\index{BasicThread@{Basic\-Thread}!BasicThread@{BasicThread}}
\index{BasicThread@{BasicThread}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Basic\-Thread::Basic\-Thread ({\bf Basic\-Functor\-Base} $\ast$ {\em functor})}\label{class_basic_thread_a1}


\index{BasicThread@{Basic\-Thread}!BasicThread@{BasicThread}}
\index{BasicThread@{BasicThread}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Basic\-Thread::Basic\-Thread (void $\ast$($\ast$ {\em start\-Routine})(void $\ast$))}\label{class_basic_thread_a2}


\index{BasicThread@{Basic\-Thread}!~BasicThread@{$\sim$BasicThread}}
\index{~BasicThread@{$\sim$BasicThread}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Basic\-Thread::$\sim${\bf Basic\-Thread} ()\hspace{0.3cm}{\tt  [virtual]}}\label{class_basic_thread_a3}




\subsection{Member Function Documentation}
\index{BasicThread@{Basic\-Thread}!cancel@{cancel}}
\index{cancel@{cancel}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::cancel ()}\label{class_basic_thread_a8}


\index{BasicThread@{Basic\-Thread}!detach@{detach}}
\index{detach@{detach}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::detach ()}\label{class_basic_thread_a9}


\index{BasicThread@{Basic\-Thread}!getData@{getData}}
\index{getData@{getData}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ Basic\-Thread::get\-Data ()\hspace{0.3cm}{\tt  [inline]}}\label{class_basic_thread_a10}


\index{BasicThread@{Basic\-Thread}!init@{init}}
\index{init@{init}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::init ()\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_d2}


This function does initializations common to all the constructors. 

It takes in a special consideration for Sun\-OS to circumvent a bug that occurs when more then one thread is started. \index{BasicThread@{Basic\-Thread}!isRunning@{isRunning}}
\index{isRunning@{isRunning}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::is\-Running ()\hspace{0.3cm}{\tt  [inline]}}\label{class_basic_thread_a13}


\index{BasicThread@{Basic\-Thread}!join@{join}}
\index{join@{join}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::join ()}\label{class_basic_thread_a7}


This causes the calling thread of execution to block until the thread of this object exits. 

\index{BasicThread@{Basic\-Thread}!onEntrance@{onEntrance}}
\index{onEntrance@{onEntrance}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::on\-Entrance ()\hspace{0.3cm}{\tt  [private, virtual]}}\label{class_basic_thread_d1}


This virtual function can be overriden by inheriting classes which would like to do some extra processing before thread startup. 

It is called by Basic\-Thread just before either the overriden {\bf run()}{\rm (p.\,\pageref{class_basic_thread_a4})} or start\-Routine function is called. \index{BasicThread@{Basic\-Thread}!onExit@{onExit}}
\index{onExit@{onExit}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::on\-Exit ()\hspace{0.3cm}{\tt  [private, virtual]}}\label{class_basic_thread_d0}


This virtual function can be overriden by inheriting classes which would like to do some extra processing on thread exit. 

It is called by Basic\-Thread just after either the overriden {\bf run()}{\rm (p.\,\pageref{class_basic_thread_a4})} or start\-Routine function returns. \index{BasicThread@{Basic\-Thread}!run@{run}}
\index{run@{run}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::run ()\hspace{0.3cm}{\tt  [virtual]}}\label{class_basic_thread_a4}


This virtual function should be overriden by inheriting process. 

This function is called by Basic\-Thread from within the new thread of execution after {\bf start()}{\rm (p.\,\pageref{class_basic_thread_a5})} is called. \index{BasicThread@{Basic\-Thread}!setData@{setData}}
\index{setData@{setData}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::set\-Data (void $\ast$ {\em data})\hspace{0.3cm}{\tt  [inline]}}\label{class_basic_thread_a11}


\index{BasicThread@{Basic\-Thread}!setRunning@{setRunning}}
\index{setRunning@{setRunning}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::set\-Running (bool {\em x})\hspace{0.3cm}{\tt  [inline]}}\label{class_basic_thread_a12}


This function is not always necessary. 

When a thread starts up it will automaticly set running to true. However if you are starting a group of threads this function is useful so the starting threads don't mistakenly think a thread has exited when it is actually just starting up. Before starting any threads in the group they can all be set to started. This gives the alusion that all the threads started at once.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em x}]True or False \end{description}
\end{Desc}
\index{BasicThread@{Basic\-Thread}!shouldShutdown@{shouldShutdown}}
\index{shouldShutdown@{shouldShutdown}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::should\-Shutdown ()}\label{class_basic_thread_a14}


This function should be called from the thread itself to determine if shutdown has been requested. 

If a thread doesn't monitor this variable {\bf stop()}{\rm (p.\,\pageref{class_basic_thread_a6})} will not work!

\begin{Desc}
\item[Returns:]True if shutdown has been requested \end{Desc}
\index{BasicThread@{Basic\-Thread}!start@{start}}
\index{start@{start}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Basic\-Thread::start ()}\label{class_basic_thread_a5}


Starts the thread. 

\index{BasicThread@{Basic\-Thread}!starter@{starter}}
\index{starter@{starter}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ Basic\-Thread::starter (void $\ast$ {\em me})\hspace{0.3cm}{\tt  [static, private]}}\label{class_basic_thread_h0}


This static function should never be called directly. 

It is used by pthreads in starting the thread.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em me}]A this pointer\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Nothing \end{Desc}
\index{BasicThread@{Basic\-Thread}!stop@{stop}}
\index{stop@{stop}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::stop ()}\label{class_basic_thread_a6}


Requests the thread stop via the shutdown variable. 

There is however no guarantee that the thread will actually stop. The running thread must check the shutdown variable and decide to stop. \index{BasicThread@{Basic\-Thread}!testCancel@{testCancel}}
\index{testCancel@{testCancel}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Basic\-Thread::test\-Cancel ()\hspace{0.3cm}{\tt  [static]}}\label{class_basic_thread_e0}




\subsection{Member Data Documentation}
\index{BasicThread@{Basic\-Thread}!attr@{attr}}
\index{attr@{attr}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}pthread\_\-attr\_\-t {\bf Basic\-Thread::attr}\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_r1}


\index{BasicThread@{Basic\-Thread}!data@{data}}
\index{data@{data}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ {\bf Basic\-Thread::data}\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_r4}


\index{BasicThread@{Basic\-Thread}!functor@{functor}}
\index{functor@{functor}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Basic\-Functor\-Base}$\ast$ {\bf Basic\-Thread::functor}\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_r2}


\index{BasicThread@{Basic\-Thread}!running@{running}}
\index{running@{running}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool {\bf Basic\-Thread::running}\hspace{0.3cm}{\tt  [protected]}}\label{class_basic_thread_p1}


\index{BasicThread@{Basic\-Thread}!shutdown@{shutdown}}
\index{shutdown@{shutdown}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool {\bf Basic\-Thread::shutdown}\hspace{0.3cm}{\tt  [protected]}}\label{class_basic_thread_p0}


\index{BasicThread@{Basic\-Thread}!startRoutine@{startRoutine}}
\index{startRoutine@{startRoutine}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void$\ast$($\ast$ {\bf Basic\-Thread::start\-Routine})(void $\ast$)\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_r3}


\index{BasicThread@{Basic\-Thread}!thread@{thread}}
\index{thread@{thread}!BasicThread@{Basic\-Thread}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}pthread\_\-t {\bf Basic\-Thread::thread}\hspace{0.3cm}{\tt  [private]}}\label{class_basic_thread_r0}




The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
{\bf Basic\-Thread.h}\item 
{\bf Basic\-Thread.cpp}\end{CompactItemize}
