Classes | |
struct | GaThreadParameter |
GaThreadParameter structure contains information needed to start new thread. It has pointer to function which is entry point of thread and pointer to parameters which will be passed to the function. Restrictions of entry point's function of a thread are described by GaThreadFunctionPointer type. More... | |
class | GaCriticalSection |
GaCriticalSection class is wrapper class for system synchronization object. More... | |
class | GaSectionLock |
GaSectionLock class is used for automatic access control with help of GaCriticalSection class. Synchronization object can be automatically acquired when instance of GaSectionLock is created. If synchronization object is locked by instance of GaSectionLock it is released when the instance goes out of scope. This mechanism provides simple way of managing critical sections because users don't have to worry about releasing of synchronization object in most cases, but for more complicated cases LOCK and UNLOCK macros can be used with instances of this class or with GaCriticalSection class. GaSectionLock is mainly employed by LOCK_OBJECT and LOCK_THIS_OBJECT . More... | |
class | GaThread |
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... | |
Typedefs | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | SystemThread |
This type defines system specific type for storing threads objects or handles to them. | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | SysSyncObject |
This type defines system specific type for storing synchronization objects or handles to them. System specific synchronization is wrapped by GaCriticalSection class. | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | SysSemaphoreObject |
This type defines system specific type for storing semaphores objects or handles to them. Manipulation over semaphores is done by MAKE_SEMAPHORE , FREE_SEMAPHORE , LOCK_SEMAPHORE and UNLOCK_SEMAPHORE macros. | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | SysEventObject |
This type defines system specific type for storing events objects or handles to them. Manipulation over events is done by MAKE_EVENT , FREE_EVENT , WAIT_FOR_EVENT and SIGNAL_EVENT macros. | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | ThreadFunctionReturn |
This type is used as return value type for functions which are used as threads' entry points. This type hides system specific types which are used for the purpose. | |
typedef _SYSTEM_OR_COMPILER_SPECIFIC_ | ThreadID |
Variables/objects of this type are used for storing threads' IDs. This type hides system specific types which are used for the purpose. | |
Enumerations | |
enum | GaThreadStatus { GATS_RUNNING = 0x1, GATS_STOPPED = 0x2, GATS_PAUSED = 0x4, GATS_NOT_RUNNING = GATS_STOPPED | GATS_PAUSED } |
This enumeration defines possible states of threads. More... | |
Functions | |
bool | MakeSemaphore (SysSemaphoreObject &semaphoreHandle, int maxCount, int initialCount) |
This function is used to create operating system object for semaphore and to initialize it. | |
bool | DeleteSemaphore (SysSemaphoreObject &semaphoreHandle) |
This function is used to free operating system semaphore. | |
bool | LockSemaphore (SysSemaphoreObject &semaphoreHandle) |
This function is used to acquire access to critical section protected by semaphore. | |
bool | UnlockSemaphore (SysSemaphoreObject &semaphoreHandle, int count) |
This function is used to release access to critical section protected by semaphore. | |
bool | MakeEvent (SysEventObject &eventHandle, bool intialState) |
This function is used to create operating system object for event and to initialize it. | |
bool | DeleteEvent (SysEventObject &eventHandle) |
This function is used to free operating system semaphore. | |
bool | WaitForEvent (SysEventObject &eventHandle) |
This function is used to block calling thread until event reaches signaled state. When calling thread is released, event is restared to non-signaled state. | |
bool | SignalEvent (SysEventObject &eventHandle) |
This function is used to set event to signaled state. | |
typedef | ThreadFunctionReturn (GACALL *ThreadFunctionPointer)(GaThread * |
ThreadFunctionPointer is pointer to function used as thread's entry point. Entry point function must obey restriction of this type: 1. Function must return value of ThreadFunctionReturn type. 2. Function must use GACALL calling convention. 3. Function must have two parameters. 4. First parameter must be pointer GaThread (GaThread*). 5. Second parameter must be pointer to void (void *). |
typedef HANDLE Threading::SysEventObject |
This type defines system specific type for storing events objects or handles to them. Manipulation over events is done by MAKE_EVENT
, FREE_EVENT
, WAIT_FOR_EVENT
and SIGNAL_EVENT
macros.
typedef HANDLE Threading::SysSemaphoreObject |
This type defines system specific type for storing semaphores objects or handles to them. Manipulation over semaphores is done by MAKE_SEMAPHORE
, FREE_SEMAPHORE
, LOCK_SEMAPHORE
and UNLOCK_SEMAPHORE
macros.
typedef CRITICAL_SECTION Threading::SysSyncObject |
This type defines system specific type for storing synchronization objects or handles to them. System specific synchronization is wrapped by GaCriticalSection class.
typedef HANDLE Threading::SystemThread |
This type defines system specific type for storing threads objects or handles to them.
typedef int Threading::ThreadFunctionReturn |
This type is used as return value type for functions which are used as threads' entry points. This type hides system specific types which are used for the purpose.
typedef DWORD Threading::ThreadID |
Variables/objects of this type are used for storing threads' IDs. This type hides system specific types which are used for the purpose.
This enumeration defines possible states of threads.
bool Threading::DeleteEvent | ( | SysEventObject & | eventHandle | ) | [inline] |
This function is used to free operating system semaphore.
eventHandle | reference to variable that holds reference to event. |
true
if the event is successfully freed.
bool Threading::DeleteSemaphore | ( | SysSemaphoreObject & | semaphoreHandle | ) | [inline] |
This function is used to free operating system semaphore.
semaphoreHandle | reference to variable that holds reference to semaphore. |
true
if the semaphore is successfully freed.
bool Threading::LockSemaphore | ( | SysSemaphoreObject & | semaphoreHandle | ) | [inline] |
This function is used to acquire access to critical section protected by semaphore.
semaphoreHandle | reference to variable that holds reference to semaphore. |
true
if the semaphore is successfully acquired.
bool Threading::MakeEvent | ( | SysEventObject & | eventHandle, | |
bool | intialState | |||
) | [inline] |
This function is used to create operating system object for event and to initialize it.
eventHandle | reference to variable which will store handle to newly created event. | |
intialState | initial state of event. Should be to true if event should be in signaled state after it is created, otherwise it should be set to false . |
true
if the event is successfully created.
bool Threading::MakeSemaphore | ( | SysSemaphoreObject & | semaphoreHandle, | |
int | maxCount, | |||
int | initialCount | |||
) | [inline] |
This function is used to create operating system object for semaphore and to initialize it.
semaphoreHandle | variable which will store handle to newly created semaphore. | |
maxCount | maximum count of semaphore, value must be greater then 0. On *nix systems this parameter is ignored. | |
initialCount | initial count of semaphore, value must be greater or equals to the 0 and less then or equals to maxCount . |
true
if the semaphore is successfully created.
bool Threading::SignalEvent | ( | SysEventObject & | eventHandle | ) | [inline] |
This function is used to set event to signaled state.
eventHandle | reference to variable that holds reference to event. |
true
if the event is successfully signaled.
typedef Threading::ThreadFunctionReturn | ( | GACALL * | ThreadFunctionPointer | ) |
ThreadFunctionPointer
is pointer to function used as thread's entry point. Entry point function must obey restriction of this type:
1. Function must return value of ThreadFunctionReturn type.
2. Function must use GACALL
calling convention.
3. Function must have two parameters.
4. First parameter must be pointer GaThread (GaThread*).
5. Second parameter must be pointer to void
(void
*).
bool Threading::UnlockSemaphore | ( | SysSemaphoreObject & | semaphoreHandle, | |
int | count | |||
) | [inline] |
This function is used to release access to critical section protected by semaphore.
semaphoreHandle | reference to variable that holds reference to semaphore. | |
count | amount by which semaphore's count is increased, value must be grater then 0 and sum of the value and current semaphore's count must be less then or equals to maximal count of semaphore. |
true
if the semaphore is successfully released.
bool Threading::WaitForEvent | ( | SysEventObject & | eventHandle | ) | [inline] |
This function is used to block calling thread until event reaches signaled state. When calling thread is released, event is restared to non-signaled state.
eventHandle | reference to variable that holds reference to event. |
true
if the thread successfully received signal.