MythTV master
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
JobQueue Class Reference

#include <libmythtv/jobqueue.h>

Inheritance diagram for JobQueue:
[legend]
Collaboration diagram for JobQueue:
[legend]

Classes

struct  JobThreadStruct
 

Public Member Functions

 JobQueue (bool master)
 
 ~JobQueue (void) override
 
void run (void) override
 
int GetRunningJobID (uint chanid, const QDateTime &recstartts)
 

Static Public Member Functions

static bool QueueRecordingJobs (const RecordingInfo &recinfo, int jobTypes=JOB_NONE)
 
static bool QueueJob (int jobType, uint chanid, const QDateTime &recstartts, const QString &args="", const QString &comment="", QString host="", int flags=0, int status=JOB_QUEUED, QDateTime schedruntime=QDateTime())
 
static bool QueueJobs (int jobTypes, uint chanid, const QDateTime &recstartts, const QString &args="", const QString &comment="", const QString &host="")
 
static int GetJobID (int jobType, uint chanid, const QDateTime &recstartts)
 
static bool GetJobInfoFromID (int jobID, int &jobType, uint &chanid, QDateTime &recstartts)
 
static bool GetJobInfoFromID (int jobID, int &jobType, uint &chanid, QString &recstartts)
 
static int GetJobTypeFromName (const QString &name)
 
static bool ChangeJobCmds (int jobID, int newCmds)
 
static bool ChangeJobCmds (int jobType, uint chanid, const QDateTime &recstartts, int newCmds)
 
static bool ChangeJobFlags (int jobID, int newFlags)
 
static bool ChangeJobStatus (int jobID, int newStatus, const QString &comment="")
 
static bool ChangeJobHost (int jobID, const QString &newHostname)
 
static bool ChangeJobComment (int jobID, const QString &comment="")
 
static bool ChangeJobArgs (int jobID, const QString &args="")
 
static bool IsJobQueuedOrRunning (int jobType, uint chanid, const QDateTime &recstartts)
 
static bool IsJobRunning (int jobType, uint chanid, const QDateTime &recstartts)
 
static bool IsJobRunning (int jobType, const ProgramInfo &pginfo)
 
static bool IsJobQueued (int jobType, uint chanid, const QDateTime &recstartts)
 
static bool IsJobStatusQueued (int status)
 
static bool IsJobStatusRunning (int status)
 
static bool PauseJob (int jobID)
 
static bool ResumeJob (int jobID)
 
static bool RestartJob (int jobID)
 
static bool StopJob (int jobID)
 
static bool DeleteJob (int jobID)
 
static bool SafeDeleteJob (int jobID, int jobType, int chanid, const QDateTime &recstartts)
 
static enum JobCmds GetJobCmd (int jobID)
 
static enum JobFlags GetJobFlags (int jobID)
 
static enum JobStatus GetJobStatus (int jobID)
 
static enum JobStatus GetJobStatus (int jobType, uint chanid, const QDateTime &recstartts)
 
static QString GetJobArgs (int jobID)
 
static int UserJobTypeToIndex (int JobType)
 
static bool DeleteAllJobs (uint chanid, const QDateTime &recstartts)
 
static void ClearJobMask (int &mask)
 
static bool JobIsInMask (int job, int mask)
 
static bool JobIsNotInMask (int job, int mask)
 
static void AddJobsToMask (int jobs, int &mask)
 
static void RemoveJobsFromMask (int jobs, int &mask)
 
static QString JobText (int jobType)
 
static QString StatusText (int status)
 
static bool HasRunningOrPendingJobs (std::chrono::minutes startingWithinMins=0min)
 
static int GetJobsInQueue (QMap< int, JobQueueEntry > &jobs, int findJobs=JOB_LIST_NOT_DONE)
 
static void RecoverQueue (bool justOld=false)
 
static void RecoverOldJobsInQueue ()
 
static void CleanupOldJobsInQueue ()
 
static bool InJobRunWindow (QDateTime jobstarttsRaw)
 

Protected Member Functions

void customEvent (QEvent *e) override
 

Private Member Functions

void ProcessQueue (void)
 
void ProcessJob (const JobQueueEntry &job)
 
bool AllowedToRun (const JobQueueEntry &job)
 
void StartChildJob (void *(*ChildThreadRoutine)(void *), int jobID)
 
void RemoveRunningJob (int id)
 
void DoTranscodeThread (int jobID)
 
void DoMetadataLookupThread (int jobID)
 
void DoFlagCommercialsThread (int jobID)
 
void DoUserJobThread (int jobID)
 

Static Private Member Functions

static bool InJobRunWindow (std::chrono::minutes orStartsWithinMins=0min)
 
static QString GetJobDescription (int jobType)
 
static QString GetJobCommand (int id, int jobType, ProgramInfo *tmpInfo)
 
static QString PrettyPrint (off_t bytes)
 
static void * TranscodeThread (void *param)
 
static void * MetadataLookupThread (void *param)
 
static void * FlagCommercialsThread (void *param)
 
static void * UserJobThread (void *param)
 

Private Attributes

QString m_hostname
 
int m_jobsRunning {0}
 
int m_jobQueueCPU {0}
 
ProgramInfom_pginfo {nullptr}
 
QRecursiveMutex * m_runningJobsLock {nullptr}
 
QMap< int, RunningJobInfom_runningJobs
 
bool m_isMaster
 
MThreadm_queueThread {nullptr}
 
QWaitCondition m_queueThreadCond
 
QMutex m_queueThreadCondLock
 
bool m_processQueue {false}
 

Friends

class QueueProcessorThread
 

Detailed Description

Definition at line 128 of file jobqueue.h.

Constructor & Destructor Documentation

◆ JobQueue()

JobQueue::JobQueue ( bool  master)
explicit

Definition at line 50 of file jobqueue.cpp.

◆ ~JobQueue()

JobQueue::~JobQueue ( void  )
override

Definition at line 72 of file jobqueue.cpp.

Member Function Documentation

◆ AddJobsToMask()

static void JobQueue::AddJobsToMask ( int  jobs,
int &  mask 
)
inlinestatic

Definition at line 201 of file jobqueue.h.

Referenced by init_jobs().

◆ AllowedToRun()

bool JobQueue::AllowedToRun ( const JobQueueEntry job)
private

Definition at line 1445 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ ChangeJobArgs()

bool JobQueue::ChangeJobArgs ( int  jobID,
const QString &  args = "" 
)
static

Definition at line 1047 of file jobqueue.cpp.

Referenced by main().

◆ ChangeJobCmds() [1/2]

bool JobQueue::ChangeJobCmds ( int  jobID,
int  newCmds 
)
static

◆ ChangeJobCmds() [2/2]

bool JobQueue::ChangeJobCmds ( int  jobType,
uint  chanid,
const QDateTime &  recstartts,
int  newCmds 
)
static

Definition at line 952 of file jobqueue.cpp.

◆ ChangeJobComment()

bool JobQueue::ChangeJobComment ( int  jobID,
const QString &  comment = "" 
)
static

◆ ChangeJobFlags()

bool JobQueue::ChangeJobFlags ( int  jobID,
int  newFlags 
)
static

Definition at line 974 of file jobqueue.cpp.

◆ ChangeJobHost()

bool JobQueue::ChangeJobHost ( int  jobID,
const QString &  newHostname 
)
static

Definition at line 1413 of file jobqueue.cpp.

Referenced by ProcessQueue(), and RecoverQueue().

◆ ChangeJobStatus()

bool JobQueue::ChangeJobStatus ( int  jobID,
int  newStatus,
const QString &  comment = "" 
)
static

◆ CleanupOldJobsInQueue()

void JobQueue::CleanupOldJobsInQueue ( )
static

Definition at line 1647 of file jobqueue.cpp.

Referenced by CleanupTask::DoRun().

◆ ClearJobMask()

static void JobQueue::ClearJobMask ( int &  mask)
inlinestatic

Definition at line 197 of file jobqueue.h.

◆ customEvent()

void JobQueue::customEvent ( QEvent *  e)
overrideprotected

Definition at line 88 of file jobqueue.cpp.

◆ DeleteAllJobs()

bool JobQueue::DeleteAllJobs ( uint  chanid,
const QDateTime &  recstartts 
)
static

Definition at line 763 of file jobqueue.cpp.

Referenced by MainServer::DoDeleteThread().

◆ DeleteJob()

bool JobQueue::DeleteJob ( int  jobID)
static

Definition at line 884 of file jobqueue.cpp.

Referenced by StatusBox::customEvent(), and QueueJob().

◆ DoFlagCommercialsThread()

void JobQueue::DoFlagCommercialsThread ( int  jobID)
private

Definition at line 2281 of file jobqueue.cpp.

Referenced by FlagCommercialsThread().

◆ DoMetadataLookupThread()

void JobQueue::DoMetadataLookupThread ( int  jobID)
private

Definition at line 2161 of file jobqueue.cpp.

Referenced by MetadataLookupThread().

◆ DoTranscodeThread()

void JobQueue::DoTranscodeThread ( int  jobID)
private

Definition at line 1935 of file jobqueue.cpp.

Referenced by TranscodeThread().

◆ DoUserJobThread()

void JobQueue::DoUserJobThread ( int  jobID)
private

Definition at line 2423 of file jobqueue.cpp.

Referenced by UserJobThread().

◆ FlagCommercialsThread()

void * JobQueue::FlagCommercialsThread ( void *  param)
staticprivate

Definition at line 2267 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ GetJobArgs()

QString JobQueue::GetJobArgs ( int  jobID)
static

Definition at line 1498 of file jobqueue.cpp.

Referenced by CompleteJob().

◆ GetJobCmd()

enum JobCmds JobQueue::GetJobCmd ( int  jobID)
static

◆ GetJobCommand()

QString JobQueue::GetJobCommand ( int  id,
int  jobType,
ProgramInfo tmpInfo 
)
staticprivate

Definition at line 1819 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ GetJobDescription()

QString JobQueue::GetJobDescription ( int  jobType)
staticprivate

Definition at line 1804 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ GetJobFlags()

enum JobFlags JobQueue::GetJobFlags ( int  jobID)
static

Definition at line 1519 of file jobqueue.cpp.

Referenced by DoTranscodeThread(), and main().

◆ GetJobID()

int JobQueue::GetJobID ( int  jobType,
uint  chanid,
const QDateTime &  recstartts 
)
static

Definition at line 656 of file jobqueue.cpp.

Referenced by customEvent(), V2Dvr::ManageJobQueue(), and SafeDeleteJob().

◆ GetJobInfoFromID() [1/2]

bool JobQueue::GetJobInfoFromID ( int  jobID,
int &  jobType,
uint chanid,
QDateTime &  recstartts 
)
static

Definition at line 677 of file jobqueue.cpp.

Referenced by GetJobInfoFromID(), and main().

◆ GetJobInfoFromID() [2/2]

bool JobQueue::GetJobInfoFromID ( int  jobID,
int &  jobType,
uint chanid,
QString &  recstartts 
)
static

Definition at line 702 of file jobqueue.cpp.

◆ GetJobsInQueue()

int JobQueue::GetJobsInQueue ( QMap< int, JobQueueEntry > &  jobs,
int  findJobs = JOB_LIST_NOT_DONE 
)
static

◆ GetJobStatus() [1/2]

enum JobStatus JobQueue::GetJobStatus ( int  jobID)
static

◆ GetJobStatus() [2/2]

enum JobStatus JobQueue::GetJobStatus ( int  jobType,
uint  chanid,
const QDateTime &  recstartts 
)
static

Definition at line 1560 of file jobqueue.cpp.

◆ GetJobTypeFromName()

int JobQueue::GetJobTypeFromName ( const QString &  name)
static

Definition at line 716 of file jobqueue.cpp.

Referenced by V2Dvr::ManageJobQueue().

◆ GetRunningJobID()

int JobQueue::GetRunningJobID ( uint  chanid,
const QDateTime &  recstartts 
)

Definition at line 1069 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ HasRunningOrPendingJobs()

bool JobQueue::HasRunningOrPendingJobs ( std::chrono::minutes  startingWithinMins = 0min)
static

Definition at line 1242 of file jobqueue.cpp.

Referenced by getStatus(), and Scheduler::HandleIdleShutdown().

◆ InJobRunWindow() [1/2]

bool JobQueue::InJobRunWindow ( QDateTime  jobstarttsRaw)
static

Definition at line 1672 of file jobqueue.cpp.

Referenced by HasRunningOrPendingJobs(), V2Dvr::ManageJobQueue(), and ProcessQueue().

◆ InJobRunWindow() [2/2]

bool JobQueue::InJobRunWindow ( std::chrono::minutes  orStartsWithinMins = 0min)
staticprivate

Definition at line 1157 of file jobqueue.cpp.

◆ IsJobQueued()

bool JobQueue::IsJobQueued ( int  jobType,
uint  chanid,
const QDateTime &  recstartts 
)
static

Definition at line 1118 of file jobqueue.cpp.

◆ IsJobQueuedOrRunning()

bool JobQueue::IsJobQueuedOrRunning ( int  jobType,
uint  chanid,
const QDateTime &  recstartts 
)
static

◆ IsJobRunning() [1/2]

bool JobQueue::IsJobRunning ( int  jobType,
const ProgramInfo pginfo 
)
static

Definition at line 1104 of file jobqueue.cpp.

◆ IsJobRunning() [2/2]

bool JobQueue::IsJobRunning ( int  jobType,
uint  chanid,
const QDateTime &  recstartts 
)
static

◆ IsJobStatusQueued()

bool JobQueue::IsJobStatusQueued ( int  status)
static

Definition at line 1087 of file jobqueue.cpp.

Referenced by IsJobQueued(), and PlaybackBox::PbbJobQueue::IsJobQueued().

◆ IsJobStatusRunning()

bool JobQueue::IsJobStatusRunning ( int  status)
static

Definition at line 1092 of file jobqueue.cpp.

Referenced by IsJobRunning(), and PlaybackBox::PbbJobQueue::IsJobRunning().

◆ JobIsInMask()

static bool JobQueue::JobIsInMask ( int  job,
int  mask 
)
inlinestatic

Definition at line 198 of file jobqueue.h.

Referenced by init_jobs().

◆ JobIsNotInMask()

static bool JobQueue::JobIsNotInMask ( int  job,
int  mask 
)
inlinestatic

Definition at line 199 of file jobqueue.h.

Referenced by init_jobs().

◆ JobText()

QString JobQueue::JobText ( int  jobType)
static

◆ MetadataLookupThread()

void * JobQueue::MetadataLookupThread ( void *  param)
staticprivate

Definition at line 2147 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ PauseJob()

bool JobQueue::PauseJob ( int  jobID)
static

Definition at line 727 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ PrettyPrint()

QString JobQueue::PrettyPrint ( off_t  bytes)
staticprivate

Definition at line 1888 of file jobqueue.cpp.

Referenced by DoTranscodeThread().

◆ ProcessJob()

void JobQueue::ProcessJob ( const JobQueueEntry job)
private

Definition at line 1702 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ ProcessQueue()

void JobQueue::ProcessQueue ( void  )
private

Definition at line 171 of file jobqueue.cpp.

Referenced by run().

◆ QueueJob()

bool JobQueue::QueueJob ( int  jobType,
uint  chanid,
const QDateTime &  recstartts,
const QString &  args = "",
const QString &  comment = "",
QString  host = "",
int  flags = 0,
int  status = JOB_QUEUED,
QDateTime  schedruntime = QDateTime() 
)
static

◆ QueueJobs()

bool JobQueue::QueueJobs ( int  jobTypes,
uint  chanid,
const QDateTime &  recstartts,
const QString &  args = "",
const QString &  comment = "",
const QString &  host = "" 
)
static

Definition at line 604 of file jobqueue.cpp.

Referenced by QueueRecordingJobs().

◆ QueueRecordingJobs()

bool JobQueue::QueueRecordingJobs ( const RecordingInfo recinfo,
int  jobTypes = JOB_NONE 
)
static

Definition at line 498 of file jobqueue.cpp.

Referenced by TVRec::FinishedRecording().

◆ RecoverOldJobsInQueue()

static void JobQueue::RecoverOldJobsInQueue ( )
inlinestatic

Definition at line 213 of file jobqueue.h.

Referenced by JobQueueRecoverTask::DoRun().

◆ RecoverQueue()

void JobQueue::RecoverQueue ( bool  justOld = false)
static

Definition at line 1584 of file jobqueue.cpp.

Referenced by run().

◆ RemoveJobsFromMask()

static void JobQueue::RemoveJobsFromMask ( int  jobs,
int &  mask 
)
inlinestatic

Definition at line 202 of file jobqueue.h.

Referenced by TVRec::FinishedRecording(), and init_jobs().

◆ RemoveRunningJob()

void JobQueue::RemoveRunningJob ( int  id)
private

◆ RestartJob()

bool JobQueue::RestartJob ( int  jobID)
static

Definition at line 745 of file jobqueue.cpp.

◆ ResumeJob()

bool JobQueue::ResumeJob ( int  jobID)
static

Definition at line 736 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ run()

void JobQueue::run ( void  )
override

Definition at line 156 of file jobqueue.cpp.

◆ SafeDeleteJob()

bool JobQueue::SafeDeleteJob ( int  jobID,
int  jobType,
int  chanid,
const QDateTime &  recstartts 
)
static

Definition at line 889 of file jobqueue.cpp.

Referenced by DeleteJob(), and V2Dvr::ManageJobQueue().

◆ StartChildJob()

void JobQueue::StartChildJob ( void *(*)(void *)  ChildThreadRoutine,
int  jobID 
)
private

Definition at line 1790 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ StatusText()

QString JobQueue::StatusText ( int  status)
static

◆ StopJob()

bool JobQueue::StopJob ( int  jobID)
static

Definition at line 754 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ TranscodeThread()

void * JobQueue::TranscodeThread ( void *  param)
staticprivate

Definition at line 1921 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ UserJobThread()

void * JobQueue::UserJobThread ( void *  param)
staticprivate

Definition at line 2409 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ UserJobTypeToIndex()

int JobQueue::UserJobTypeToIndex ( int  JobType)
static

Friends And Related Function Documentation

◆ QueueProcessorThread

friend class QueueProcessorThread
friend

Definition at line 132 of file jobqueue.h.

Member Data Documentation

◆ m_hostname

QString JobQueue::m_hostname
private

Definition at line 257 of file jobqueue.h.

Referenced by AllowedToRun(), and ProcessQueue().

◆ m_isMaster

bool JobQueue::m_isMaster
private

Definition at line 270 of file jobqueue.h.

◆ m_jobQueueCPU

int JobQueue::m_jobQueueCPU {0}
private

Definition at line 260 of file jobqueue.h.

Referenced by DoTranscodeThread(), DoUserJobThread(), and JobQueue().

◆ m_jobsRunning

int JobQueue::m_jobsRunning {0}
private

Definition at line 259 of file jobqueue.h.

Referenced by ProcessQueue().

◆ m_pginfo

ProgramInfo* JobQueue::m_pginfo {nullptr}
private

Definition at line 262 of file jobqueue.h.

◆ m_processQueue

bool JobQueue::m_processQueue {false}
private

Definition at line 275 of file jobqueue.h.

Referenced by JobQueue(), ProcessQueue(), and ~JobQueue().

◆ m_queueThread

MThread* JobQueue::m_queueThread {nullptr}
private

Definition at line 272 of file jobqueue.h.

Referenced by JobQueue(), and ~JobQueue().

◆ m_queueThreadCond

QWaitCondition JobQueue::m_queueThreadCond
private

Definition at line 273 of file jobqueue.h.

Referenced by ProcessQueue(), run(), and ~JobQueue().

◆ m_queueThreadCondLock

QMutex JobQueue::m_queueThreadCondLock
private

Definition at line 274 of file jobqueue.h.

Referenced by JobQueue(), ProcessQueue(), run(), and ~JobQueue().

◆ m_runningJobs

QMap<int, RunningJobInfo> JobQueue::m_runningJobs
private

◆ m_runningJobsLock

QRecursiveMutex* JobQueue::m_runningJobsLock {nullptr}
private

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