39#ifdef GECODE_THREADS_WINDOWS
46# define _WIN32_WINNT 0x400
49#ifndef WIN32_LEAN_AND_MEAN
50# define WIN32_LEAN_AND_MEAN
57#ifdef GECODE_THREADS_PTHREADS
61#ifdef GECODE_THREADS_OSX_UNFAIR
64#include <libkern/OSAtomic.h>
85namespace Gecode {
namespace Support {
98#if defined(GECODE_THREADS_WINDOWS)
100 CRITICAL_SECTION w_cs;
101#elif defined(GECODE_THREADS_OSX_UNFAIR)
104 os_unfair_lock unfair_lck;
105#pragma clang diagnostic push
106#pragma clang diagnostic ignored "-Wdeprecated-declarations"
108#pragma clang diagnostic pop
110#elif defined(GECODE_THREADS_PTHREADS)
114#error No suitable mutex implementation found
128 static void*
operator new(
size_t s);
130 static void operator delete(
void*
p);
135 void operator=(
const Mutex&) {}
138#ifndef GECODE_THREADS_PTHREADS_SPINLOCK
161 pthread_spinlock_t p_s;
168 bool tryacquire(
void);
174 static void*
operator new(
size_t s);
176 static void operator delete(
void*
p);
204 void operator=(
const Lock&) {}
217#ifdef GECODE_THREADS_WINDOWS
221#ifdef GECODE_THREADS_PTHREADS
242 void operator=(
const Event&) {}
278 virtual void run(
void) = 0;
282 static void*
operator new(
size_t s);
284 static void operator delete(
void*
p);
316 static void*
operator new(
size_t s);
318 static void operator delete(
void*
p);
336 static void sleep(
unsigned int ms);
338 static unsigned int npu(
void);
343 void operator=(
const Thread&) {}
union Gecode::@603::NNF::@65 u
Union depending on nodetype t.
int p
Number of positive literals for node type.
An event for synchronization.
void wait(void)
Wait until the event becomes signalled.
Event(void)
Initialize event.
~Event(void)
Delete event.
void signal(void)
Signal the event.
A lock as a scoped frontend for a mutex.
Lock(Mutex &m0)
Enter lock.
A mutex for mutual exclausion among several threads.
Mutex(void)
Initialize mutex.
~Mutex(void)
Delete mutex.
void release(void)
Release the mutex.
bool tryacquire(void)
Try to acquire the mutex, return true if succesful.
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.
Runnable * r
Runnable object to execute.
Run(Runnable *r)
Create a new thread.
Mutex m
Mutex for synchronization.
static Run * idle
Idle runners.
static void run(Runnable *r)
Construct a new thread and run r.
static void sleep(unsigned int ms)
Put current thread to sleep for ms milliseconds.
static Mutex * m(void)
Mutex for synchronization.
static unsigned int npu(void)
Return number of processing units (1 if information not available)
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
#define GECODE_SUPPORT_EXPORT