40#ifdef GECODE_HAS_THREADS
43#include <condition_variable>
45#ifdef GECODE_USE_OSX_UNFAIR_MUTEX
47#include <libkern/OSAtomic.h>
80#ifdef GECODE_HAS_THREADS
81#ifndef GECODE_USE_OSX_UNFAIR_MUTEX
99 static void*
operator new(
size_t s);
101 static void operator delete(
void* p);
106 void operator=(
const Mutex&) {}
127 void operator=(
const Lock&) {}
140#ifdef GECODE_HAS_THREADS
144 std::condition_variable c;
159 void operator=(
const Event&) {}
195 virtual void run(
void) = 0;
199 static void*
operator new(
size_t s);
201 static void operator delete(
void* p);
221 std::atomic<Runnable*>
r;
231 static void*
operator new(
size_t s);
233 static void operator delete(
void* p);
251 static void sleep(
unsigned int ms);
253 static unsigned int npu(
void);
260 Thread(
const Thread&) {}
262 void operator=(
const Thread&) {}
An event for synchronization.
void wait(void)
Wait until the event becomes signalled.
Event(void)
Initialize event.
void signal(void)
Signal the event.
Lock(Mutex &m0)
Enter lock.
A mutex for mutual exclausion among several threads.
Mutex(void)
Initialize mutex.
void release(void)
Release the mutex.
bool tryacquire(void)
Try to acquire the mutex, return true if successful.
void acquire(void)
Acquire the mutex and possibly block.
An interface for objects that can be run by a thread.
Runnable(bool d=true)
Initialize, d defines whether object is deleted when terminated.
bool todelete(void) const
Return whether to be deleted upon termination.
virtual void run(void)=0
The function that is executed when the thread starts.
virtual Terminator * terminator(void) const
Return terminator object.
virtual ~Runnable(void)
Destructor.
An interface for objects that can be called after a thread has terminated (after running the thread's...
virtual ~Terminator()
Destructor.
virtual void terminated(void)=0
The function that is called when the thread has terminated.
void run(Runnable *r)
Run a runnable object.
void exec(void)
Infinite loop for execution.
Event e
Event to wait for next runnable object to execute.
std::atomic< Runnable * > r
Runnable object to execute.
Run(Runnable *r)
Create a new thread.
static void releaseGlobalMutex(Mutex *m)
release globally acquired mutex m
static void run(Runnable *r)
Construct a new thread and run r.
static Mutex * m(void)
Mutex for synchronization.
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
static void acquireGlobalMutex(Mutex *m)
acquire mutex m globally and possibly lock
static Run * idle
Idle runners.
static unsigned int npu(void)
Return number of processing units (1 if information not available).
Support algorithms and datastructures
Gecode toplevel namespace
#define GECODE_SUPPORT_EXPORT