43 #ifdef GECODE_THREADS_WINDOWS
50 # define _WIN32_WINNT 0x400
53 #ifndef WIN32_LEAN_AND_MEAN
54 # define WIN32_LEAN_AND_MEAN
61 #ifdef GECODE_THREADS_PTHREADS
65 #ifdef GECODE_THREADS_OSX
67 #include <libkern/OSAtomic.h>
88 namespace Gecode {
namespace Support {
101 #ifdef GECODE_THREADS_WINDOWS
102 CRITICAL_SECTION w_cs;
105 #ifdef GECODE_THREADS_PTHREADS
121 static void*
operator new(
size_t s);
123 static void operator delete(
void*
p);
128 void operator=(
const Mutex&) {}
131 #if defined(GECODE_THREADS_WINDOWS) || !defined(GECODE_THREADS_PTHREADS)
137 #ifdef GECODE_THREADS_PTHREADS
139 #if defined(GECODE_THREADS_OSX) || defined(GECODE_THREADS_PTHREADS_SPINLOCK)
157 #ifdef GECODE_THREADS_OSX
161 pthread_spinlock_t p_s;
176 static void*
operator new(
size_t s);
178 static void operator delete(
void*
p);
183 void operator=(
const FastMutex&) {}
212 void operator=(
const Lock&) {}
225 #ifdef GECODE_THREADS_WINDOWS
229 #ifdef GECODE_THREADS_PTHREADS
250 void operator=(
const Event&) {}
261 virtual void run(
void) = 0;
265 static void*
operator new(
size_t s);
267 static void operator delete(
void*
p);
299 static void*
operator new(
size_t s);
301 static void operator delete(
void*
p);
319 static void sleep(
unsigned int ms);
321 static unsigned int npu(
void);
326 void operator=(
const Thread&) {}
static unsigned int npu(void)
Return number of processing units (1 if information not available)
Mutex m
Mutex for synchronization.
virtual ~Runnable(void)
Destructor.
An interface for objects that can be run by a thread.
Mutex(void)
Initialize mutex.
static void run(Runnable *r)
Construct a new thread and run r.
void acquire(void)
Acquire the mutex and possibly block.
void signal(void)
Signal the event.
Runnable * r
Runnable object to execute.
A mutex for mutual exclausion among several threads.
void release(void)
Release the mutex.
void run(Runnable *r)
Run a runnable object.
int p
Number of positive literals for node type.
An event for synchronization.
A lock as a scoped frontend for a mutex.
virtual void run(void)=0
The function that is executed when the thread starts.
Lock(Mutex &m0)
Enter lock.
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
void exec(void)
Infinite loop for execution.
bool tryacquire(void)
Try to acquire the mutex, return true if succesful.
~Event(void)
Delete event.
#define GECODE_SUPPORT_EXPORT
~Mutex(void)
Delete mutex.
static Run * idle
Idle runners.
Event(void)
Initialize event.
Event e
Event to wait for next runnable object to execute.
static Mutex * m(void)
Mutex for synchronization.
Gecode toplevel namespace
void wait(void)
Wait until the event becomes signalled.
Run(Runnable *r)
Create a new thread.