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

#include <jobqueue.h>

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

Classes

struct  jobthreadstruct
 

Public Member Functions

 JobQueue (bool master)
 
 ~JobQueue (void)
 
void customEvent (QEvent *e) override
 
int GetRunningJobID (uint chanid, const QDateTime &recstartts)
 

Static Public Member Functions

static bool QueueRecordingJobs (const RecordingInfo &, int jobTypes=JOB_NONE)
 
static bool QueueJob (int jobType, uint chanid, const QDateTime &recstartts, QString args="", QString comment="", QString host="", int flags=0, int status=JOB_QUEUED, QDateTime schedruntime=QDateTime())
 
static bool QueueJobs (int jobTypes, uint chanid, const QDateTime &recstartts, QString args="", QString comment="", 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, QString comment="")
 
static bool ChangeJobHost (int jobID, QString newHostname)
 
static bool ChangeJobComment (int jobID, QString comment="")
 
static bool ChangeJobArgs (int jobID, 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, 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 (int startingWithinMins=0)
 
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)
 

Private Types

typedef struct JobQueue::jobthreadstruct JobThreadStruct
 

Private Member Functions

void run (void) override
 
void ProcessQueue (void)
 
void ProcessJob (JobQueueEntry job)
 
bool AllowedToRun (JobQueueEntry job)
 
void StartChildJob (void *(*start_routine)(void *), int jobID)
 
QString GetJobDescription (int jobType)
 
QString GetJobCommand (int id, int jobType, ProgramInfo *tmpInfo)
 
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 (int orStartingWithinMins=0)
 
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 jobsRunning
 
int jobQueueCPU
 
ProgramInfom_pginfo
 
QMutex controlFlagsLock
 
QMap< QString, int * > jobControlFlags
 
QMutex * runningJobsLock
 
QMap< int, RunningJobInforunningJobs
 
bool isMaster
 
MThreadqueueThread
 
QWaitCondition queueThreadCond
 
QMutex queueThreadCondLock
 
bool processQueue
 

Friends

class QueueProcessorThread
 

Detailed Description

Definition at line 127 of file jobqueue.h.

Member Typedef Documentation

◆ JobThreadStruct

Constructor & Destructor Documentation

◆ JobQueue()

JobQueue::JobQueue ( bool  master)
explicit

Definition at line 46 of file jobqueue.cpp.

◆ ~JobQueue()

JobQueue::~JobQueue ( void  )

Definition at line 71 of file jobqueue.cpp.

Member Function Documentation

◆ customEvent()

void JobQueue::customEvent ( QEvent *  e)
override

Definition at line 87 of file jobqueue.cpp.

◆ QueueRecordingJobs()

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

Definition at line 500 of file jobqueue.cpp.

Referenced by TVRec::FinishedRecording().

◆ QueueJob()

bool JobQueue::QueueJob ( int  jobType,
uint  chanid,
const QDateTime &  recstartts,
QString  args = "",
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,
QString  args = "",
QString  comment = "",
QString  host = "" 
)
static

Definition at line 612 of file jobqueue.cpp.

Referenced by QueueRecordingJobs().

◆ GetJobID()

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

Definition at line 658 of file jobqueue.cpp.

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

◆ GetJobInfoFromID() [1/2]

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

Definition at line 683 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 712 of file jobqueue.cpp.

◆ GetJobTypeFromName()

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

Definition at line 726 of file jobqueue.cpp.

Referenced by Dvr::ManageJobQueue().

◆ 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 963 of file jobqueue.cpp.

◆ ChangeJobFlags()

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

Definition at line 985 of file jobqueue.cpp.

◆ ChangeJobStatus()

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

◆ ChangeJobHost()

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

Definition at line 1421 of file jobqueue.cpp.

Referenced by ProcessQueue(), and RecoverQueue().

◆ ChangeJobComment()

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

◆ ChangeJobArgs()

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

Definition at line 1058 of file jobqueue.cpp.

Referenced by main().

◆ IsJobQueuedOrRunning()

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

◆ GetRunningJobID()

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

Definition at line 1080 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ IsJobRunning() [1/2]

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

◆ IsJobRunning() [2/2]

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

Definition at line 1118 of file jobqueue.cpp.

◆ IsJobQueued()

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

Definition at line 1135 of file jobqueue.cpp.

◆ IsJobStatusQueued()

bool JobQueue::IsJobStatusQueued ( int  status)
static

Definition at line 1101 of file jobqueue.cpp.

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

◆ IsJobStatusRunning()

bool JobQueue::IsJobStatusRunning ( int  status)
static

Definition at line 1106 of file jobqueue.cpp.

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

◆ PauseJob()

bool JobQueue::PauseJob ( int  jobID)
static

Definition at line 738 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ ResumeJob()

bool JobQueue::ResumeJob ( int  jobID)
static

Definition at line 747 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ RestartJob()

bool JobQueue::RestartJob ( int  jobID)
static

Definition at line 756 of file jobqueue.cpp.

◆ StopJob()

bool JobQueue::StopJob ( int  jobID)
static

Definition at line 765 of file jobqueue.cpp.

Referenced by StatusBox::customEvent().

◆ DeleteJob()

bool JobQueue::DeleteJob ( int  jobID)
static

Definition at line 895 of file jobqueue.cpp.

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

◆ SafeDeleteJob()

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

Definition at line 900 of file jobqueue.cpp.

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

◆ GetJobCmd()

enum JobCmds JobQueue::GetJobCmd ( int  jobID)
static

◆ GetJobFlags()

enum JobFlags JobQueue::GetJobFlags ( int  jobID)
static

Definition at line 1530 of file jobqueue.cpp.

Referenced by DoTranscodeThread(), and main().

◆ 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 1571 of file jobqueue.cpp.

◆ GetJobArgs()

QString JobQueue::GetJobArgs ( int  jobID)
static

Definition at line 1509 of file jobqueue.cpp.

Referenced by CompleteJob().

◆ UserJobTypeToIndex()

int JobQueue::UserJobTypeToIndex ( int  JobType)
static

◆ DeleteAllJobs()

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

Definition at line 774 of file jobqueue.cpp.

Referenced by MainServer::DoDeleteThread().

◆ ClearJobMask()

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

Definition at line 196 of file jobqueue.h.

◆ JobIsInMask()

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

Definition at line 197 of file jobqueue.h.

Referenced by init_jobs().

◆ JobIsNotInMask()

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

Definition at line 198 of file jobqueue.h.

Referenced by init_jobs().

◆ AddJobsToMask()

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

Definition at line 200 of file jobqueue.h.

Referenced by init_jobs().

◆ RemoveJobsFromMask()

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

Definition at line 201 of file jobqueue.h.

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

◆ JobText()

QString JobQueue::JobText ( int  jobType)
static

◆ StatusText()

QString JobQueue::StatusText ( int  status)
static

◆ HasRunningOrPendingJobs()

bool JobQueue::HasRunningOrPendingJobs ( int  startingWithinMins = 0)
static

Definition at line 1250 of file jobqueue.cpp.

Referenced by getStatus().

◆ GetJobsInQueue()

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

◆ RecoverQueue()

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

Definition at line 1595 of file jobqueue.cpp.

Referenced by run().

◆ RecoverOldJobsInQueue()

static void JobQueue::RecoverOldJobsInQueue ( )
inlinestatic

Definition at line 212 of file jobqueue.h.

Referenced by JobQueueRecoverTask::DoRun().

◆ CleanupOldJobsInQueue()

void JobQueue::CleanupOldJobsInQueue ( )
static

Definition at line 1658 of file jobqueue.cpp.

Referenced by CleanupTask::DoRun().

◆ InJobRunWindow() [1/2]

bool JobQueue::InJobRunWindow ( QDateTime  jobstarttsRaw)
static

Definition at line 1683 of file jobqueue.cpp.

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

◆ run()

void JobQueue::run ( void  )
overrideprivate

Definition at line 151 of file jobqueue.cpp.

◆ ProcessQueue()

void JobQueue::ProcessQueue ( void  )
private

Definition at line 166 of file jobqueue.cpp.

Referenced by run().

◆ ProcessJob()

void JobQueue::ProcessJob ( JobQueueEntry  job)
private

Definition at line 1713 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ AllowedToRun()

bool JobQueue::AllowedToRun ( JobQueueEntry  job)
private

Definition at line 1456 of file jobqueue.cpp.

Referenced by ProcessQueue().

◆ InJobRunWindow() [2/2]

bool JobQueue::InJobRunWindow ( int  orStartingWithinMins = 0)
staticprivate

Definition at line 1171 of file jobqueue.cpp.

◆ StartChildJob()

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

Definition at line 1802 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ GetJobDescription()

QString JobQueue::GetJobDescription ( int  jobType)
private

Definition at line 1816 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ GetJobCommand()

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

Definition at line 1831 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ RemoveRunningJob()

void JobQueue::RemoveRunningJob ( int  id)
private

◆ PrettyPrint()

QString JobQueue::PrettyPrint ( off_t  bytes)
staticprivate

Definition at line 1900 of file jobqueue.cpp.

Referenced by DoTranscodeThread().

◆ TranscodeThread()

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

Definition at line 1933 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ DoTranscodeThread()

void JobQueue::DoTranscodeThread ( int  jobID)
private

Definition at line 1947 of file jobqueue.cpp.

Referenced by TranscodeThread().

◆ MetadataLookupThread()

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

Definition at line 2163 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ DoMetadataLookupThread()

void JobQueue::DoMetadataLookupThread ( int  jobID)
private

Definition at line 2177 of file jobqueue.cpp.

Referenced by MetadataLookupThread().

◆ FlagCommercialsThread()

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

Definition at line 2288 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ DoFlagCommercialsThread()

void JobQueue::DoFlagCommercialsThread ( int  jobID)
private

Definition at line 2302 of file jobqueue.cpp.

Referenced by FlagCommercialsThread().

◆ UserJobThread()

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

Definition at line 2435 of file jobqueue.cpp.

Referenced by ProcessJob().

◆ DoUserJobThread()

void JobQueue::DoUserJobThread ( int  jobID)
private

Definition at line 2449 of file jobqueue.cpp.

Referenced by UserJobThread().

Friends And Related Function Documentation

◆ QueueProcessorThread

friend class QueueProcessorThread
friend

Definition at line 131 of file jobqueue.h.

Member Data Documentation

◆ m_hostname

QString JobQueue::m_hostname
private

Definition at line 254 of file jobqueue.h.

Referenced by AllowedToRun(), and ProcessQueue().

◆ jobsRunning

int JobQueue::jobsRunning
private

Definition at line 256 of file jobqueue.h.

Referenced by ProcessQueue().

◆ jobQueueCPU

int JobQueue::jobQueueCPU
private

Definition at line 257 of file jobqueue.h.

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

◆ m_pginfo

ProgramInfo* JobQueue::m_pginfo
private

Definition at line 259 of file jobqueue.h.

◆ controlFlagsLock

QMutex JobQueue::controlFlagsLock
private

Definition at line 261 of file jobqueue.h.

◆ jobControlFlags

QMap<QString, int *> JobQueue::jobControlFlags
private

Definition at line 262 of file jobqueue.h.

◆ runningJobsLock

QMutex* JobQueue::runningJobsLock
private

◆ runningJobs

QMap<int, RunningJobInfo> JobQueue::runningJobs
private

◆ isMaster

bool JobQueue::isMaster
private

Definition at line 267 of file jobqueue.h.

◆ queueThread

MThread* JobQueue::queueThread
private

Definition at line 269 of file jobqueue.h.

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

◆ queueThreadCond

QWaitCondition JobQueue::queueThreadCond
private

Definition at line 270 of file jobqueue.h.

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

◆ queueThreadCondLock

QMutex JobQueue::queueThreadCondLock
private

Definition at line 271 of file jobqueue.h.

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

◆ processQueue

bool JobQueue::processQueue
private

Definition at line 272 of file jobqueue.h.

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


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