38 template<
class RetType>
42 virtual RetType
run(
int i) = 0;
48 template<
class RetType>
57 RetType
result(
void)
const;
60 template<
class Jobs,
class RetType>
92 virtual void run(
void);
120 void stop(RetType
r,
int i);
122 bool done(
void)
const;
124 Master(Jobs& j,
unsigned int m);
126 bool run(RetType&
r);
145 virtual void run(
void);
151 RunJobs(Jobs& j,
unsigned int m);
153 bool run(RetType&
r);
155 bool stopped(
int& i, RetType&
r)
const;
162 template<
class RetType>
166 template<
class RetType>
174 template<
class Jobs,
class RetType>
181 template<
class Jobs,
class RetType>
185 template<
class Jobs,
class RetType>
192 template<
class Jobs,
class RetType>
198 template<
class Jobs,
class RetType>
214 template<
class Jobs,
class RetType>
223 template<
class Jobs,
class RetType>
235 template<
class Jobs,
class RetType>
247 }
while (
job != NULL);
250 template<
class Jobs,
class RetType>
256 template<
class Jobs,
class RetType>
270 template<
class Jobs,
class RetType>
301 template<
class Jobs,
class RetType>
314 template<
class Jobs,
class RetType>
323 template<
class Jobs,
class RetType>
328 template<
class Jobs,
class RetType>
338 template<
class Jobs,
class RetType>
345 template<
class Jobs,
class RetType>
350 template<
class Jobs,
class RetType>
356 template<
class Jobs,
class RetType>
359 if (!
master->needthread())
Queue with arbitrary number of elements.
An event for synchronization.
Class to throw an exception to stop new jobs from being started.
RetType r
The result stored.
JobStop(RetType r0)
Constructor.
RetType result(void) const
Return the passed result.
Baseclass for jobs with return type RetType.
virtual ~Job(void)
Destructor.
virtual RetType run(int i)=0
Run a job with iterator index i.
A mutex for mutual exclausion among several threads.
A class to delete the master (running in parallel)
virtual void run(void)
Perform deletion.
Master * master
The master to be deleted.
Deleter(Master *m)
Initialize with master m.
void stop(RetType r, int i)
Report that a job with index i has been stopped.
int idx
Index of next job to be created.
RetType sres
Result from a the first stopped job (passed in exception)
Job< RetType > * next(int &i)
Get next job witth index i, if possible.
int sidx
Index of the first stop that has been stopped (-1 if none)
bool stopped(void) const
Whether a job has thrown a JobStop exception.
Event e
Event is triggered if a the first job is added to queue.
DynamicQueue< RetType, Heap > rs
Queue of not yet requested results.
bool needthread(void)
Whether a new thread is needed for deletion.
Mutex m
Mutex for synchronizing access.
unsigned int n_threads
Number of threads currently not in use.
void report(RetType r)
Report result r by a worker.
bool run(RetType &r)
Run next job and return true if succesful and assign r to its result.
int stoppedjob(RetType &r) const
Return index of first job that has thrown a JobStop exception (-1 if none) with its result.
Master(Jobs &j, unsigned int m)
Initialize with job iterator j and maximal number of threads m.
bool done(void) const
Test whether all jobs are done.
The actual worker using a thread to run a job.
int idx
Original iterator index of job.
virtual void run(void)
Run jobs.
Worker(Job< RetType > *j, Master *m, int i)
Initialize worker.
Master * master
The master to communicate with.
virtual ~Worker(void)
Nothing to delete (done in run)
Job< RetType > * job
The job to run.
Master * master
The actual master.
RunJobs(Jobs &j, unsigned int m)
Initialize with job iterator j and maximal number of threads m.
bool run(RetType &r)
Run next job and return true if succesful and assign r to its result.
bool stopped(int &i, RetType &r) const
Whether a job has thrown a JobStop exception with index i and result r.
~RunJobs(void)
Destructor.
Runnable(bool d=true)
Initialize, d defines whether object is deleted when terminated.
static void run(Runnable *r)
Construct a new thread and run r.
Heap heap
The single global heap.
Support algorithms and datastructures
Gecode toplevel namespace
Post propagator for SetVar SetOpType SetVar SetRelType r
#define GECODE_NEVER
Assert that this command is never executed.