19 #ifndef __XRD_CL_JOB_MANAGER_HH__
20 #define __XRD_CL_JOB_MANAGER_HH__
44 virtual void Run(
void *arg ) = 0;
59 pWorkers.resize( workers );
94 pJobs.
Put( JobHelper( job, arg ) );
104 pthread_t thread = pthread_self();
105 std::vector<pthread_t>::iterator itr =
106 std::find( pWorkers.begin(), pWorkers.end(), thread );
107 return itr != pWorkers.end();
114 void StopWorkers( uint32_t n );
118 JobHelper(
Job *j = 0,
void *a = 0 ): job(j), arg(a) {}
123 std::vector<pthread_t> pWorkers;
124 SyncQueue<JobHelper> pJobs;
bool Finalize()
Finalize the job manager, clear the queues.
bool Start()
Start the workers.
bool Initialize()
Initialize the job manager.
void RunJobs()
Run the jobs.
bool Stop()
Stop the workers.
void QueueJob(Job *job, void *arg=0)
Add a job to be run.
JobManager(uint32_t workers)
Constructor.
Interface for a job to be run by the job manager.
virtual void Run(void *arg)=0
The job logic.
virtual ~Job()
Virtual destructor.
void Put(const Item &item)
Put the item in the queue.