Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
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 CCDDARipper CGUIDialogSubtitles CGUIDialogVideoBookmarks CGUIWindowFileManager CMusicLibraryQueue CPictureThumbLoader CTextureCache CVideoLibraryQueue CVideoThumbLoader

Public Member Functions

 CJobQueue (bool lifo=false, unsigned int jobsAtOnce=1, CJob::PRIORITY priority=CJob::PRIORITY_LOW)
 CJobQueue constructor. More...
 
 ~CJobQueue () override
 CJobQueue destructor Cancels any in-process jobs, and destroys the job queue. More...
 
bool AddJob (CJob *job)
 Add a job to the queue On completion of the job (or destruction of the job queue) the CJob object will be destroyed. More...
 
template<typename F >
void Submit (F &&f)
 Add a function f to this job queue. More...
 
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. More...
 
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. More...
 
bool IsProcessing () const
 Check whether the queue is processing a job. More...
 
void OnJobComplete (unsigned int jobID, bool success, CJob *job) override
 The callback used when a job completes. More...
 
- Public Member Functions inherited from IJobCallback
virtual ~IJobCallback ()=default
 Destructor for job call back objects. More...
 
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. More...
 

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. More...
 

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 (or destruction of the job queue) the CJob object will be destroyed.

Parameters
joba pointer to the job to add. The job should be subclassed from CJob.
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.

◆ OnJobComplete()

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

The callback used when a job completes.

OnJobComplete is called at the completion of the CJob::DoWork function, and is used to return information to the caller on the result of the job. On returning from this function the CJobManager will destroy this job.

Subclasses should override this function if they wish to transfer information from the job prior to it's deletion. They must then call this base class function, which will move on to the next job.

See also
CJobManager, IJobCallback and CJob

Implements IJobCallback.

Reimplemented in CGUIDialogSubtitles, CGUIDialogVideoBookmarks, CVideoLibraryQueue, CVideoThumbLoader, and CGUIWindowFileManager.

◆ 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: