|
|
|
DESCRIPTION:
|
This class demostrate how to realize synchronization using mutex and semaphore.You can modify it to fit your use easily I think.
|
|
|
METHOD:
|
CQueue_ELEMENT (STRUCT)
|
|
DESCRIPTION:
|
The public CQueue_ELEMENT structure defines what a queue data element looks like. A real-life application would generally not require this information.
|
|
|
m_nThreadNum
|
A member of this structure.
|
|
|
m_nRequestNum
|
A member of this structure.
|
|
|
METHOD:
|
CONSTRUCTOR (:DWORD)
|
|
DESCRIPTION:
|
Initialize mutex and semaphore, and allocate memory for CQueue_ELEMENT array.
|
|
|
nMaxElements
|
Max number of CQueue_ELEMENT array.
|
|
|
|
METHOD:
|
destructor (NONE)
|
|
DESCRIPTION:
|
Do some clean work.Close mutex and semaphore,free memory for CQueue_ELEMENT array.
|
|
|
|
METHOD:
|
Append (:DWORD, :DWORD)
|
|
DESCRIPTION:
|
Append new element to the queue.
|
|
|
pElement
|
Pointer of the new CQueue_ELEMENT.
|
|
|
dwTimeout
|
Timeouts for waiting for appending.
|
|
|
RETURN:
|
FALSE if failed,Call GetLastError for more info.
|
|
|
METHOD:
|
Remove (:DWORD, :DWORD)
|
|
DESCRIPTION:
|
Remove a ELEMENT from the queen.
|
|
|
pElement
|
if have,the pointer of a CQueue_ELEMENT that has been removed.
|
|
|
dwTimeout
|
Timeouts for waiting for removing.
|
|
|
RETURN:
|
FALSE if failed,Call GetLastError for more info.
|
|
|