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 { 00056 //Create the semaphore 00057 m_hSemaphore=CreateSemaphore(NULL, 00058 lInitialCount, 00059 lMaxCount, 00060 pSemaphoreName); 00061 00062 //Did we create the semaphore? 00063 if (!m_hSemaphore) 00064 throw std::string("Failed to create semaphore!"); 00065 00066 //Check if we are the owners 00067 if (pSemaphoreName && 00068 GetLastError()!=ERROR_ALREADY_EXISTS) 00069 SetFirst(); 00070 }
Definition at line 83 of file Win32Semaphore.cpp. 00084 { 00085 if (m_hSemaphore) 00086 //Close the semaphore 00087 CloseHandle(m_hSemaphore); 00088 }
Definition at line 72 of file Win32Semaphore.cpp. 00075 : CGenericSemaphore(lInitialCount, 00076 lMaxCount, 00077 pSemaphoreName), 00078 m_hSemaphore(NULL) 00079 00080 { 00081 }
Member Function Documentation
Implements CGenericSemaphore. Definition at line 95 of file Win32Semaphore.cpp. 00096 { 00097 DWORD dwWaitResult; 00098 00099 //Wait for the semaphore 00100 dwWaitResult=WaitForSingleObject(m_hSemaphore, 00101 ulMSTimeout); 00102 00103 //Check why did we quit 00104 return dwWaitResult==WAIT_TIMEOUT; 00105 }
Implements CGenericSemaphore. Definition at line 107 of file Win32Semaphore.cpp. 00108 { 00109 long lOld; 00110 BOOL bResult; 00111 00112 //Release it 00113 bResult=ReleaseSemaphore(m_hSemaphore, 00114 lAmount, 00115 &lOld); 00116 00117 //Check if it's an error 00118 if (bResult) 00119 return lOld; 00120 else 00121 return -1; 00122 }
Implements CWaitableObject. Definition at line 129 of file Win32Semaphore.cpp. 00130 { 00131 Release(); 00132 }
The documentation for this class was generated from the following files: |