News SF.net Project Frequently Asked Questions Documentation Downloads Mailing Lists How to Contribute

SourceForge.net Logo

Changing the way games are made and played.

TNL::Semaphore class Reference

TNL::Semaphore Class Reference

#include <tnlThread.h>


Detailed Description

Platform independent semaphore class.

The semaphore class wraps OS specific semaphore functionality for thread synchronization.


Public Member Functions

 Semaphore (U32 initialCount=0, U32 maximumCount=1024)
 Semaphore constructor - initialCount specifies how many wait calls will be let through before an increment is required.

 ~Semaphore ()
void wait ()
 Thread calling wait will block as long as the semaphore's count is zero.

void increment (U32 count=1)
 Increments the semaphore's internal count.


Private Attributes

sem_t mSemaphore


Constructor & Destructor Documentation

TNL::Semaphore::Semaphore U32  initialCount = 0,
U32  maximumCount = 1024
 

Semaphore constructor - initialCount specifies how many wait calls will be let through before an increment is required.

TNL::Semaphore::~Semaphore  ) 
 


Member Function Documentation

void TNL::Semaphore::wait  ) 
 

Thread calling wait will block as long as the semaphore's count is zero.

If the semaphore is incremented, one of the waiting threads will be awakened and the semaphore will decrement.

void TNL::Semaphore::increment U32  count = 1  ) 
 

Increments the semaphore's internal count.

This will wake count threads that are waiting on this semaphore.


Field Documentation

sem_t TNL::Semaphore::mSemaphore [private]