CWin32Semaphore Class Reference#include <Win32Semaphore.h>
Inheritance diagram for CWin32Semaphore:
![]()
Collaboration diagram for CWin32Semaphore:
![]()
Detailed DescriptionDefinition at line 47 of file Win32Semaphore.h. Constructor & Destructor Documentation
Definition at line 49 of file Win32Semaphore.cpp. 00051 : CGenericSemaphore(lInitialCount, 00052 lMaxCount, 00053 pSemaphoreName), 00054 m_hSemaphore(0), 00055 m_bDontDelete(FALSE) 00056 { 00057 //Create the semaphore 00058 m_hSemaphore=CreateSemaphore(NULL, 00059 lInitialCount, 00060 lMaxCount, 00061 pSemaphoreName); 00062 00063 //Did we create the semaphore? 00064 if (!m_hSemaphore) 00065 throw std::string("Failed to create semaphore!"); 00066 00067 //Check if we are the owners 00068 if (pSemaphoreName && 00069 GetLastError()!=ERROR_ALREADY_EXISTS) 00070 SetFirst(); 00071 }
Definition at line 73 of file Win32Semaphore.cpp. 00074 { 00075 if (m_hSemaphore) 00076 //Close the semaphore 00077 CloseHandle(m_hSemaphore); 00078 }
Member Function Documentation
Implements CGenericSemaphore. Definition at line 80 of file Win32Semaphore.cpp. 00081 { 00082 DWORD dwWaitResult; 00083 00084 //Wait for the semaphore 00085 dwWaitResult=WaitForSingleObject(m_hSemaphore, 00086 ulMSTimeout); 00087 00088 //Check why did we quit 00089 return dwWaitResult==WAIT_TIMEOUT; 00090 }
Implements CGenericSemaphore. Definition at line 92 of file Win32Semaphore.cpp. 00093 { 00094 long lOld; 00095 BOOL bResult; 00096 00097 //Release it 00098 bResult=ReleaseSemaphore(m_hSemaphore, 00099 lAmount, 00100 &lOld); 00101 00102 //Check if it's an error 00103 if (bResult) 00104 return lOld; 00105 else 00106 return -1; 00107 }
Implements CWaitableObject. Definition at line 114 of file Win32Semaphore.cpp. 00115 { 00116 Release(); 00117 }
The documentation for this class was generated from the following files: |