GaThread
class controls system threads. It wraps system specific control of threading. This class has built-in synchronizator so it is allowed to use LOCK_OBJECT
and LOCK_THIS_OBJECT
macros with instances of this class.
More...
#include <D:/Temp/vs/gal/source/Threading.h>
Public Member Functions | |
GAL_API | GaThread (const GaThreadParameter ¶meters, bool started) |
Initializes thread object and stores thread parameters. If user specified, thread can be started automatically when object is created. | |
GAL_API | ~GaThread () |
Stops thread if it is running and releases system object and closes handles to it. | |
GAL_API bool GACALL | Start () |
Method starts execution of the thread or resumes execution if it was suspended. If thread already running or system is unable to start/resume thread call fails and method returns false . | |
GAL_API bool GACALL | Pause () |
Method suspends thread execution if it is running. If thread is stopped or system cannot suspend thread, call fails and method returns false . Pause method is intended only for debugging purposes. | |
GAL_API bool GACALL | Abort () |
Method stops execution of thread forcibly. Calling this method can cause problems thread cannot release acquired resources properly and do necessary cleanups. | |
GAL_API bool GACALL | Join () |
Suspends execution of thread from which it was called until thread which is managed by this instance of GaThread class finish execution. | |
GaThreadStatus GACALL | Status () |
This method is thread-safe. | |
ThreadID GACALL | GetId () |
This method is thread-safe. | |
Static Private Member Functions | |
static ThreadFunctionReturn APICALL | ThreadFunctionWraper (GaThread *thread) |
This method is used as entry point of new thread. Operating system calls this method when it starts thread. After that, when thread enters ThreadFunctionWrapper it calls user entry point which is specified in thread parameters. | |
Private Attributes | |
GaThreadStatus | _status |
This attribute holds running status of the thread. | |
SystemThread | _thread |
System specific the thread object or handle to it. | |
ThreadID | _id |
stores identification number of thread if it is running or it is suspended. | |
GaThreadParameter | _parameters |
User defined information (thread's entry point and custom parameters passed to the thread) needed to start thread. |
GaThread
class controls system threads. It wraps system specific control of threading. This class has built-in synchronizator so it is allowed to use LOCK_OBJECT
and LOCK_THIS_OBJECT
macros with instances of this class.
Threading::GaThread::GaThread | ( | const GaThreadParameter & | parameters, | |
bool | started | |||
) |
Initializes thread object and stores thread parameters. If user specified, thread can be started automatically when object is created.
parameters | thread parameters (entry point and pointer to custom parameters passed to the thread). | |
started | if this parameter is set to true then thread start execution immediately. |
Threading::GaThread::~GaThread | ( | ) |
Stops thread if it is running and releases system object and closes handles to it.
bool Threading::GaThread::Start | ( | ) |
Method starts execution of the thread or resumes execution if it was suspended. If thread already running or system is unable to start/resume thread call fails and method returns false
.
This method is thread-safe.
true
if thread is started/resumed successfully. If thread was in running state or system is unable to start/resume thread method returns false
.bool Threading::GaThread::Pause | ( | ) |
Method suspends thread execution if it is running. If thread is stopped or system cannot suspend thread, call fails and method returns false
. Pause method is intended only for debugging purposes.
This method is not implemented on *nix systems.
This method is thread-safe.
true
if thread is suspended successfully. If thread was stopped or system couldn't suspend thread method returns false
.bool Threading::GaThread::Abort | ( | ) |
Method stops execution of thread forcibly. Calling this method can cause problems thread cannot release acquired resources properly and do necessary cleanups.
This method is thread-safe.
true
if thread is stopped successfully. If thread was stopped or system couldn't stop thread method returns false
.bool Threading::GaThread::Join | ( | ) |
Suspends execution of thread from which it was called until thread which is managed by this instance of GaThread
class finish execution.
This method is thread-safe.
true
if waiting has finished successfully. If there was an error method returns false
.GaThreadStatus GACALL Threading::GaThread::Status | ( | ) | [inline] |
This method is thread-safe.
ThreadID GACALL Threading::GaThread::GetId | ( | ) | [inline] |
This method is thread-safe.
ThreadFunctionReturn Threading::GaThread::ThreadFunctionWraper | ( | GaThread * | thread | ) | [static, private] |
This method is used as entry point of new thread. Operating system calls this method when it starts thread. After that, when thread enters ThreadFunctionWrapper
it calls user entry point which is specified in thread parameters.
pointer to object which manages new thread. |
GaThreadStatus Threading::GaThread::_status [private] |
This attribute holds running status of the thread.
SystemThread Threading::GaThread::_thread [private] |
System specific the thread object or handle to it.
ThreadID Threading::GaThread::_id [private] |
stores identification number of thread if it is running or it is suspended.
User defined information (thread's entry point and custom parameters passed to the thread) needed to start thread.