Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CJobQueue Class Reference

Job Queue class to handle a queue of unique jobs to be processed sequentially. More...

#include <JobManager.h>

Inheritance diagram for CJobQueue:
IJobCallback CGUIDialogSubtitles CGUIWindowFileManager CMusicLibraryQueue CTextureCache CVideoLibraryQueue KODI::CDRIP::CCDDARipper

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.
 

Detailed Description

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.

See also
CJob and IJobCallback

Constructor & Destructor Documentation

◆ CJobQueue()

CJobQueue::CJobQueue ( bool lifo = false,
unsigned int jobsAtOnce = 1,
CJob::PRIORITY priority = CJob::PRIORITY_LOW )

CJobQueue constructor.

Parameters
lifowhether the queue should be processed last in first out or first in first out. Defaults to false (first in first out)
jobsAtOncenumber of jobs at once to process. Defaults to 1.
prioritypriority of this queue.
See also
CJob

◆ ~CJobQueue()

CJobQueue::~CJobQueue ( )
override

CJobQueue destructor Cancels any in-process jobs, and destroys the job queue.

See also
CJob

Member Function Documentation

◆ AddJob()

bool CJobQueue::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.

Parameters
joba pointer to the job to add. The job should be subclassed from CJob.
Returns
True if the job was added successfully, false otherwise. In case of failure, the passed CJob object will be deleted before returning from this method.
See also
CJob

◆ CancelJob()

void CJobQueue::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.

Parameters
joba pointer to the job to cancel. The job should be subclassed from CJob.
See also
CJob

◆ CancelJobs()

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.

See also
CJob

◆ IsProcessing()

bool CJobQueue::IsProcessing ( ) const

Check whether the queue is processing a job.

◆ OnJobAbort()

void CJobQueue::OnJobAbort ( unsigned int jobID,
CJob * job )
overridevirtual

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.

Parameters
jobIDthe unique id of the job (as retrieved from CJobManager::AddJob)
jobthe job that has been aborted.
See also
CJobManager, IJobCallback and CJob

Reimplemented from IJobCallback.

◆ OnJobComplete()

void CJobQueue::OnJobComplete ( unsigned int jobID,
bool success,
CJob * job )
overridevirtual

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.

Parameters
jobIDthe unique id of the job (as retrieved from CJobManager::AddJob)
successthe result from the DoWork call
jobthe job that has been processed.
See also
CJobManager, IJobCallback and CJob

Implements IJobCallback.

Reimplemented in CMusicLibraryQueue, and CVideoLibraryQueue.

◆ QueueEmpty()

bool CJobQueue::QueueEmpty ( ) const
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.

◆ Submit()

template<typename F >
void CJobQueue::Submit ( F && f)
inline

Add a function f to this job queue.


The documentation for this class was generated from the following files: