12 #include "threads/CriticalSection.h" 13 #include "threads/Thread.h" 27 void Process()
override;
42 bool operator==(
const CJob *job)
const override 68 explicit CJobPointer(
CJob *job)
79 bool operator==(
const CJob *job)
const 113 bool AddJob(
CJob *job);
132 void CancelJob(
const CJob *job);
145 bool IsProcessing()
const;
158 void OnJobComplete(
unsigned int jobID,
bool success,
CJob *job)
override;
170 void OnJobAbort(
unsigned int jobID,
CJob* job)
override;
177 bool QueueEmpty()
const;
180 void OnJobNotify(
CJob* job);
183 typedef std::deque<CJobPointer> Queue;
184 typedef std::vector<CJobPointer> Processing;
186 Processing m_processing;
188 unsigned int m_jobsAtOnce;
190 mutable CCriticalSection m_section;
214 m_callback = callback;
215 m_priority = priority;
217 bool operator==(
unsigned int jobID)
const 219 return m_id == jobID;
221 bool operator==(
const CJob *job)
const 261 AddJob(
new CLambdaJob<F>(std::forward<F>(f)),
nullptr, priority);
270 AddJob(
new CLambdaJob<F>(std::forward<F>(f)), callback, priority);
278 void CancelJob(
unsigned int jobID);
300 int IsProcessing(
const std::string &type)
const;
352 bool OnJobProgress(
unsigned int progress,
unsigned int total,
const CJob *job)
const;
367 unsigned int m_jobCounter;
369 typedef std::deque<CWorkItem> JobQueue;
370 typedef std::vector<CWorkItem> Processing;
371 typedef std::vector<CJobWorker*> Workers;
373 JobQueue m_jobQueue[CJob::PRIORITY_DEDICATED + 1];
375 Processing m_processing;
378 mutable CCriticalSection m_section;
void Submit(F &&f)
Add a function f to this job queue.
Definition: JobManager.h:119
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
virtual void OnJobProgress(unsigned int jobID, unsigned int progress, unsigned int total, const CJob *job)
An optional callback function that a job may call while processing.
Definition: Job.h:80
Definition: JobManager.h:21
void Submit(F &&f, IJobCallback *callback, CJob::PRIORITY priority=CJob::PRIORITY_LOW)
Add a function f to this job manager for asynchronously execution.
Definition: JobManager.h:268
Base class for jobs that are executed asynchronously.
Definition: Job.h:109
void Submit(F &&f, CJob::PRIORITY priority=CJob::PRIORITY_LOW)
Add a function f to this job manager for asynchronously execution.
Definition: JobManager.h:259
Job Manager class for scheduling asynchronous jobs.
Definition: JobManager.h:205
Definition: JobManager.h:33
bool DoWork() override
Main workhorse function of CJob instances.
Definition: JobManager.h:37
Callback interface for asynchronous jobs.
Definition: Job.h:31
void OnJobComplete(unsigned int jobID, bool success, CJob *job) override
The callback used when a job completes.
Definition: JobManager.cpp:81
PRIORITY
Priority levels for jobs, specified by clients when adding jobs to the CJobManager.
Definition: Job.h:116
Job Queue class to handle a queue of unique jobs to be processed sequentially.
Definition: JobManager.h:63