LSemaphore is a PowerPlant class that is used for implementing semaphores. Most of the methods and members are internal to PowerPlant.
Methods :
The methods in this class are:
Data Members:
The data members in this class are:
Operation:
The only two methods you will typically concern yourself with are Wait() and Signal().
Source files:
See also:
Purpose:
The constructor creates the object.
Access :
Prototype:
LSemaphore();
LSemaphore(SInt32 initialCount);
LSemaphore(const LSemaphore&);Parameters:
SInt32 containing the initial count to set the semaphore at, or a semaphore to make a copy of.
Purpose:
The destructor destroys the LSemaphore object.
Access :
Prototype:
~LSemaphore();
Purpose:
Block the current thread for the given number of milliseconds, refer to Wait().
NOTE: The current thread must be in a 1-level-deep critical section upon entering this function!
Access :
Prototype:
ExceptionCode BlockThread(SInt32 milliSeconds);Parameters:
SInt32 containing the number of msec to block for.
Return:
Purpose:
Initializes the fields of a semaphore.
Access :
Prototype:
void InitSemaphore(SInt32 initialCount);Parameters:
The initial count to set the semaphore to.
Return:
Purpose:
Release a semaphore. If any threads are waiting on the semaphore, one of them is unblocked.
Access :
Prototype:
virtual void Signal();Parameters:
Return:
Purpose:
Unblock all of the threads waiting on this semaphore, passing them the given error code.
Access :
Prototype:
void UnblockAll(ExceptionCode error);Parameters:
Return:
Purpose:
Unblock the thread pointed to by qEl, passing it the given error code.
NOTE: The current thread must be in a critical section upon entering this method!
Access :
Prototype:
LThread* UnblockThread(QElemPtr qEl,
ExceptionCode error); The parameters for this method are:
Return:
Purpose:
Wait for a semaphore to become available. An optional argument specifies how long the caller is willing to wait for the semaphore to become available. Possible values are:
semaphore_WaitForever Wait indefinitely (default).
semaphore_NoWait Do not wait. If the semaphore is unavailable, return errSemaphoreTimedOut.
If the time interval expires before the semaphore becomes available, this function returns errSemaphoreTimedOut.
Access :
Prototype:
ExceptionCode Wait(SInt32 milliSeconds);Parameters:
Return:
Purpose:
Access :
Prototype:
LSemaphore& operator = (const LSemaphore&);Parameters:
Return:
Purpose:
Access :
Prototype:
SInt32 mExcessSignals;
Purpose:
Access :
Prototype:
QHdr mThreads;