Home
Install
Use
Develop
Support
News
Credits
hosted by
|
11 #ifndef __BatchQueue_h
12 #define __BatchQueue_h
14 #include "ThreadContext.h"
31 void resize ( unsigned nthread);
40 template< class Class, typename Method>
41 void submit (Class* instance, Method method);
44 template< class Class, typename Method, typename Argument>
45 void submit (Class* instance, Method method, Argument argument);
48 template< class Class, typename Method, typename Arg1, typename Arg2>
49 void submit (Class* instance, Method method, Arg1 a1, Arg2 a2);
70 class BatchQueue::Job {
80 virtual void execute () = 0;
91 template< class Class, typename Method>
94 class Job0 : public Job {
96 void execute () { functor (); }
98 Job0 (Class* instance, Method method) : functor (instance, method) {}
101 submit ( new Job0( instance, method ));
104 template< class Class, typename Method, typename Argument>
107 class Job1 : public Job {
108 Functor< void(Argument) > functor;
110 void execute () { functor (argument); }
112 Job1 (Class* instance, Method method, Argument arg)
113 : functor (instance, method) { argument = arg; }
116 submit ( new Job1( instance, method, arg ));
119 template< class Class, typename Method, typename Arg1, typename Arg2>
122 class Job2 : public Job {
123 Functor< void(Arg1, Arg2) > functor;
126 void execute () { functor (arg1, arg2); }
128 Job2 (Class* instance, Method method, Arg1 a1, Arg2 a2)
129 : functor (instance, method) { arg1 = a1; arg2 = a2; }
132 submit ( new Job2( instance, method, a1, a2 ));
135 #endif // !defined(__BatchQueue_h)
std::vector< Job * > active The active jobs. Definition: BatchQueue.h:71
void add(Job *) Add a job to the active list.
void remove(Job *) Remove a job from the active list.
Locks the mutex on construction and unlocks on deletion. Definition: ThreadContext.h:56
A convenient exception handling class. Definition: Error.h:54
void submit(Job *) Submit a job for processing. Definition: BatchQueue.C:218
void resize(unsigned nthread) Set the number of tasks that may run at one time. Definition: BatchQueue.C:227
BatchQueue(unsigned nthread=0) Default constructor. Definition: BatchQueue.C:20
ThreadContext * context Mutual exclusion and condition variables used to coordinate the queue. Definition: BatchQueue.h:68
void wait() Wait for completion of all active jobs. Definition: BatchQueue.C:223
Implements an adaptable function object in compliance with the STL. Definition: Functor.h:39
ThreadContext class. Definition: ThreadContext.h:15
const std::string get_message() const Get the error message. Definition: Error.C:133
~BatchQueue() Destructor. Definition: BatchQueue.C:33
Runs multiple threads using a simple batch queue model. Definition: BatchQueue.h:20
Generated using doxygen 1.8.17
|