|
Kodi Docs 20.0
Kodi is an open source media player and entertainment hub.
|
Job Manager class for scheduling asynchronous jobs. More...
#include <JobManager.h>
Public Member Functions | |
| unsigned int | AddJob (CJob *job, IJobCallback *callback, CJob::PRIORITY priority=CJob::PRIORITY_LOW) |
| Add a job to the threaded job manager. On completion or abort of the job or in case the job could not be added successfully, the CJob object will be destroyed. More... | |
| template<typename F > | |
| void | Submit (F &&f, CJob::PRIORITY priority=CJob::PRIORITY_LOW) |
| Add a function f to this job manager for asynchronously execution. More... | |
| template<typename F > | |
| void | Submit (F &&f, IJobCallback *callback, CJob::PRIORITY priority=CJob::PRIORITY_LOW) |
| Add a function f to this job manager for asynchronously execution. More... | |
| void | CancelJob (unsigned int jobID) |
| Cancel a job with the given id. More... | |
| void | CancelJobs () |
| Cancel all remaining jobs, preparing for shutdown Should be called prior to destroying any objects that may be being used as callbacks. More... | |
| void | Restart () |
| Re-start accepting jobs again Called after calling CancelJobs() to allow this manager to accept more jobs. More... | |
| int | IsProcessing (const std::string &type) const |
| Checks to see if any jobs of a specific type are currently processing. More... | |
| void | PauseJobs () |
| Suspends queueing of jobs with priority PRIORITY_LOW_PAUSABLE until unpaused Useful to (for ex) stop queuing thumb jobs during video start/playback. Does not affect currently processing jobs, use IsProcessing to see if any need to be waited on. More... | |
| void | UnPauseJobs () |
| Resumes queueing of (previously paused) jobs with priority PRIORITY_LOW_PAUSABLE. More... | |
| bool | IsProcessing (const CJob::PRIORITY &priority) const |
| Checks to see if any jobs with specific priority are currently processing. More... | |
Static Public Member Functions | |
| static CJobManager & | GetInstance () |
| The only way through which the global instance of the CJobManager should be accessed. More... | |
Protected Member Functions | |
| CJob * | GetNextJob (const CJobWorker *worker) |
| Get a new job to process. Blocks until a new job is available, or a timeout has occurred. More... | |
| void | OnJobComplete (bool success, CJob *job) |
| Callback from CJobWorker after a job has completed. Calls IJobCallback::OnJobComplete(), and then destroys job. More... | |
| bool | OnJobProgress (unsigned int progress, unsigned int total, const CJob *job) const |
| Callback from CJob to report progress and check for cancellation. Checks for cancellation, and calls IJobCallback::OnJobProgress(). More... | |
Friends | |
| class | CJobWorker |
| class | CJob |
| class | CJobQueue |
Job Manager class for scheduling asynchronous jobs.
Controls asynchronous job execution, by allowing clients to add and cancel jobs. Should be accessed via CJobManager::GetInstance(). Jobs are allocated based on priority levels. Lower priority jobs are executed only if there are sufficient spare worker threads free to allow for higher priority jobs that may arise.
| unsigned int CJobManager::AddJob | ( | CJob * | job, |
| IJobCallback * | callback, | ||
| CJob::PRIORITY | priority = CJob::PRIORITY_LOW |
||
| ) |
Add a job to the threaded job manager. On completion or abort of the job 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 |
| callback | a pointer to an IJobCallback instance to receive job progress and completion notices. |
| priority | the priority that this job should run at. |
| void CJobManager::CancelJobs | ( | ) |
Cancel all remaining jobs, preparing for shutdown Should be called prior to destroying any objects that may be being used as callbacks.
|
static |
The only way through which the global instance of the CJobManager should be accessed.
|
protected |
Get a new job to process. Blocks until a new job is available, or a timeout has occurred.
| worker | a pointer to the current CJobWorker instance requesting a job. |
| bool CJobManager::IsProcessing | ( | const CJob::PRIORITY & | priority | ) | const |
Checks to see if any jobs with specific priority are currently processing.
| priority | to search for |
| int CJobManager::IsProcessing | ( | const std::string & | type | ) | const |
Checks to see if any jobs of a specific type are currently processing.
| type | Job type to search for |
Callback from CJobWorker after a job has completed. Calls IJobCallback::OnJobComplete(), and then destroys job.
| job | a pointer to the calling subclassed CJob instance. |
| success | the result from the DoWork call |
|
protected |
Callback from CJob to report progress and check for cancellation. Checks for cancellation, and calls IJobCallback::OnJobProgress().
| progress | amount of processing performed to date, out of total. |
| total | total amount of processing. |
| job | pointer to the calling subclassed CJob instance. |
| void CJobManager::PauseJobs | ( | ) |
Suspends queueing of jobs with priority PRIORITY_LOW_PAUSABLE until unpaused Useful to (for ex) stop queuing thumb jobs during video start/playback. Does not affect currently processing jobs, use IsProcessing to see if any need to be waited on.
| void CJobManager::Restart | ( | ) |
Re-start accepting jobs again Called after calling CancelJobs() to allow this manager to accept more jobs.
| std::logic_error | if the manager was not previously cancelled |
|
inline |
Add a function f to this job manager for asynchronously execution.
|
inline |
Add a function f to this job manager for asynchronously execution.
| void CJobManager::UnPauseJobs | ( | ) |
Resumes queueing of (previously paused) jobs with priority PRIORITY_LOW_PAUSABLE.
|
friend |
|
friend |
|
friend |