38 namespace Gecode {
namespace Support {
45 InitializeCriticalSection(&w_cs);
49 EnterCriticalSection(&w_cs);
53 return TryEnterCriticalSection(&w_cs) != 0;
57 LeaveCriticalSection(&w_cs);
61 DeleteCriticalSection(&w_cs);
70 : w_h(CreateEvent(NULL, FALSE, FALSE, NULL)) {
72 throw OperatingSystemError(
"Event::Event[Windows::CreateEvent]");
76 if (SetEvent(w_h) == 0)
77 throw OperatingSystemError(
"Event::signal[Windows::SetEvent]");
81 if (WaitForSingleObject(w_h,INFINITE) != 0)
82 throw OperatingSystemError(
"Event::wait[Windows::WaitForSingleObject]");
86 if (CloseHandle(w_h) == 0)
87 throw OperatingSystemError(
"Event::~Event[Windows::CloseHandle]");
96 Sleep(static_cast<DWORD>(ms));
103 return static_cast<unsigned int>(si.dwNumberOfProcessors);
static unsigned int npu(void)
Return number of processing units (1 if information not available)
Mutex(void)
Initialize mutex.
void acquire(void)
Acquire the mutex and possibly block.
void signal(void)
Signal the event.
void release(void)
Release the mutex.
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
bool tryacquire(void)
Try to acquire the mutex, return true if succesful.
~Event(void)
Delete event.
~Mutex(void)
Delete mutex.
Event(void)
Initialize event.
Gecode toplevel namespace
void wait(void)
Wait until the event becomes signalled.