Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Job Queue class to handle a queue of unique jobs to be processed sequentially. More...
#include <JobManager.h>
Public Member Functions | |
CJobQueue (bool lifo=false, unsigned int jobsAtOnce=1, CJob::PRIORITY priority=CJob::PRIORITY_LOW) | |
CJobQueue constructor. | |
~CJobQueue () override | |
CJobQueue destructor Cancels any in-process jobs, and destroys the job queue. | |
bool | AddJob (CJob *job) |
Add a job to the queue On completion of the job, destruction of the job queue or in case the job could not be added successfully, the CJob object will be destroyed. | |
template<typename F > | |
void | Submit (F &&f) |
Add a function f to this job queue. | |
void | CancelJob (const CJob *job) |
Cancel a job in the queue Cancels a job in the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed. If the job is only queued then it will be removed from the queue and deleted. | |
void | CancelJobs () |
Cancel all jobs in the queue Removes all jobs from the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed. | |
bool | IsProcessing () const |
Check whether the queue is processing a job. | |
void | OnJobComplete (unsigned int jobID, bool success, CJob *job) override |
The callback used when a job completes. | |
void | OnJobAbort (unsigned int jobID, CJob *job) override |
The callback used when a job will be aborted. | |
Public Member Functions inherited from IJobCallback | |
virtual | ~IJobCallback ()=default |
Destructor for job call back objects. | |
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. | |
Protected Member Functions | |
bool | QueueEmpty () const |
Returns if we still have jobs waiting to be processed NOTE: This function does not take into account the jobs that are currently processing. | |
Job Queue class to handle a queue of unique jobs to be processed sequentially.
Holds a queue of jobs to be processed sequentially, either first in,first out or last in, first out. Jobs are unique, so queueing multiple copies of the same job (based on the CJob::operator==) will not add additional jobs.
Classes should subclass this class and override OnJobCallback should they require information from the job.
CJobQueue::CJobQueue | ( | bool | lifo = false, |
unsigned int | jobsAtOnce = 1, | ||
CJob::PRIORITY | priority = CJob::PRIORITY_LOW ) |
|
override |
Add a job to the queue On completion of the job, destruction of the job queue or in case the job could not be added successfully, the CJob object will be destroyed.
job | a pointer to the job to add. The job should be subclassed from CJob. |
Cancel a job in the queue Cancels a job in the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed. If the job is only queued then it will be removed from the queue and deleted.
job | a pointer to the job to cancel. The job should be subclassed from CJob. |
void CJobQueue::CancelJobs | ( | ) |
Cancel all jobs in the queue Removes all jobs from the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed.
bool CJobQueue::IsProcessing | ( | ) | const |
Check whether the queue is processing a job.
The callback used when a job will be aborted.
CJobQueue implementation will cleanup the internal processing queue and then queue the next job at the job manager, if any.
jobID | the unique id of the job (as retrieved from CJobManager::AddJob) |
job | the job that has been aborted. |
Reimplemented from IJobCallback.
The callback used when a job completes.
CJobQueue implementation will cleanup the internal processing queue and then queue the next job at the job manager, if any.
jobID | the unique id of the job (as retrieved from CJobManager::AddJob) |
success | the result from the DoWork call |
job | the job that has been processed. |
Implements IJobCallback.
Reimplemented in CMusicLibraryQueue, and CVideoLibraryQueue.
|
protected |
Returns if we still have jobs waiting to be processed NOTE: This function does not take into account the jobs that are currently processing.
|
inline |
Add a function f to this job queue.