foobar2000 SDK  2015-08-03
Public Member Functions | Private Member Functions | Private Attributes
CMutexScope

#include <win32_misc.h>

Public Member Functions

 CMutexScope (CMutex &mutex, DWORD timeOutMS, const char *timeOutBugMsg)
 
 CMutexScope (CMutex &mutex)
 
 CMutexScope (CMutex &mutex, abort_callback &aborter)
 
 ~CMutexScope ()
 

Private Member Functions

 CMutexScope (const CMutexScope &)
 
void operator= (const CMutexScope &)
 

Private Attributes

CMutexm_mutex
 

Detailed Description

Definition at line 365 of file win32_misc.h.

Constructor & Destructor Documentation

CMutexScope::CMutexScope ( CMutex mutex,
DWORD  timeOutMS,
const char *  timeOutBugMsg 
)

Definition at line 252 of file win32_misc.cpp.

252  : m_mutex(mutex) {
253  SetLastError(0);
254  const unsigned div = 4;
255  for(unsigned walk = 0; walk < div; ++walk) {
256  switch(WaitForSingleObject( m_mutex.Handle(), timeOutMS/div ) ) {
257  case WAIT_FAILED:
258  WIN32_OP_FAIL_CRITICAL("WaitForSingleObject");
259  case WAIT_OBJECT_0:
260  return;
261  case WAIT_TIMEOUT:
262  break;
263  default:
264  uBugCheck();
265  }
266  }
267  TRACK_CODE(timeOutBugMsg, uBugCheck());
268 }
DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
Definition: pp-winapi.h:16
HANDLE Handle()
Definition: win32_misc.h:356
CMutex & m_mutex
Definition: win32_misc.h:373
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char *what)
Definition: win32_misc.cpp:58
PFC_NORETURN void SHARED_EXPORT uBugCheck()
CMutexScope::CMutexScope ( CMutex mutex)

Definition at line 270 of file win32_misc.cpp.

270  : m_mutex(mutex) {
271  SetLastError(0);
272  switch(WaitForSingleObject( m_mutex.Handle(), INFINITE ) ) {
273  case WAIT_FAILED:
274  WIN32_OP_FAIL_CRITICAL("WaitForSingleObject");
275  case WAIT_OBJECT_0:
276  return;
277  default:
278  uBugCheck();
279  }
280 }
DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
Definition: pp-winapi.h:16
HANDLE Handle()
Definition: win32_misc.h:356
CMutex & m_mutex
Definition: win32_misc.h:373
PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char *what)
Definition: win32_misc.cpp:58
PFC_NORETURN void SHARED_EXPORT uBugCheck()
CMutexScope::CMutexScope ( CMutex mutex,
abort_callback aborter 
)

Definition at line 282 of file win32_misc.cpp.

282  : m_mutex(mutex) {
283  mutex.Acquire( aborter );
284 }
CMutex & m_mutex
Definition: win32_misc.h:373
void Acquire(abort_callback &aborter)
Definition: win32_misc.cpp:243
CMutexScope::~CMutexScope ( )

Definition at line 286 of file win32_misc.cpp.

286  {
287  ReleaseMutex(m_mutex.Handle());
288 }
HANDLE Handle()
Definition: win32_misc.h:356
CMutex & m_mutex
Definition: win32_misc.h:373
CMutexScope::CMutexScope ( const CMutexScope )
private

Member Function Documentation

void CMutexScope::operator= ( const CMutexScope )
private

Field Documentation

CMutex& CMutexScope::m_mutex
private

Definition at line 373 of file win32_misc.h.


The documentation for this class was generated from the following files: