DDraceNetwork Docs
|
#include <jobs.h>
Public Types | |
enum | EJobState { STATE_QUEUED = 0 , STATE_RUNNING , STATE_DONE , STATE_ABORTED } |
Public Member Functions | |
IJob () | |
virtual | ~IJob () |
IJob (const IJob &Other)=delete | |
IJob & | operator= (const IJob &Other)=delete |
EJobState | State () const |
bool | Done () const |
virtual bool | Abort () |
bool | IsAbortable () const |
Protected Member Functions | |
virtual void | Run ()=0 |
void | Abortable (bool Abortable) |
Private Attributes | |
std::shared_ptr< IJob > | m_pNext |
std::atomic< EJobState > | m_State |
std::atomic< bool > | m_Abortable |
Friends | |
class | CJobPool |
A job which runs in a worker thread of a job pool.
enum IJob::EJobState |
The state of a job in the job pool.
Enumerator | |
---|---|
STATE_QUEUED | Job has been created/queued but not started on a worker thread yet. |
STATE_RUNNING | Job is currently running on a worker thread. |
STATE_DONE | Job was completed successfully. |
STATE_ABORTED | Job was aborted. Note the job may or may not still be running while in this state.
|
IJob::IJob | ( | ) |
|
virtualdefault |
|
delete |
|
virtual |
Aborts the job, if it can be aborted.
true
if abort was accepted, false
otherwise.Reimplemented in CChooseMaster::CJob, and CSkins::CSkinDownloadJob.
|
protected |
Sets whether this job can be aborted.
bool IJob::Done | ( | ) | const |
Returns whether the job was completed, i.e. whether it's not still queued or running.
true
if the job is done, false
otherwise. bool IJob::IsAbortable | ( | ) | const |
Returns whether the job can be aborted. Jobs that are abortable may have their state set to STATE_ABORTED
at any point if the job was aborted. The job state should be checked periodically in the Run
function and the job should terminate at the earliest, safe opportunity when aborted. Scheduled jobs which are not abortable are guaranteed to fully complete before the job pool is shut down.
true
if the job can be aborted, false
otherwise.
|
protectedpure virtual |
Performs tasks in a worker thread.
Implemented in CDemoEdit, CScreenshotSaveJob, CRegister::CProtocol::CJob, CHostLookup, CMenus::CCommunityIconLoadJob, CSoundLoading, CDataFileWriterFinishJob, CJob, CChooseMaster::CJob, and CSkins::CSkinDownloadJob.
IJob::EJobState IJob::State | ( | ) | const |
Returns the state of the job.
IJob
is generally not thread-safe unless the job is in STATE_DONE or has not been enqueued yet.
|
friend |
|
private |
|
private |
|
private |