Scheduler Class Reference

#include <scheduler.h>

Inheritance diagram for Scheduler:
MThread MythScheduler

List of all members.

Public Member Functions

 Scheduler (bool runthread, QMap< int, EncoderLink * > *tvList, QString recordTbl="record", Scheduler *master_sched=NULL)
 ~Scheduler ()
void Stop (void)
void Wait (void)
void SetExpirer (AutoExpire *autoExpirer)
void Reschedule (int recordid)
void AddRecording (const RecordingInfo &)
void FillRecordListFromDB (int recordid=-1)
void FillRecordListFromMaster (void)
void UpdateRecStatus (RecordingInfo *pginfo)
void UpdateRecStatus (uint cardid, uint chanid, const QDateTime &startts, RecStatusType recstatus, const QDateTime &recendts)
bool GetAllPending (RecList &retList) const
virtual void GetAllPending (QStringList &strList) const
virtual QMap< QString,
ProgramInfo * > 
GetRecording (void) const
void getAllScheduled (QStringList &strList)
void getConflicting (RecordingInfo *pginfo, QStringList &strlist)
void getConflicting (RecordingInfo *pginfo, RecList *retlist)
void PrintList (bool onlyFutureRecordings=false)
void PrintList (RecList &list, bool onlyFutureRecordings=false)
void PrintRec (const RecordingInfo *p, const char *prefix=NULL)
void SetMainServer (MainServer *ms)
void SlaveConnected (RecordingList &slavelist)
void SlaveDisconnected (uint cardid)
void DisableScheduling (void)
void EnableScheduling (void)
void GetNextLiveTVDir (uint cardid)
void ResetIdleTime (void)
bool WasStartedAutomatically ()
RecStatusType GetRecStatus (const ProgramInfo &pginfo)
int GetError (void) const

Protected Member Functions

virtual void run (void)
 Run's the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Private Types

typedef pair< const
RecordingInfo *, const
RecordingInfo * > 
IsSameKey
typedef QMap< IsSameKey, boolIsSameCacheType

Private Member Functions

bool VerifyCards (void)
bool FillRecordList (void)
void UpdateMatches (int recordid)
void UpdateManuals (int recordid)
void BuildWorkList (void)
bool ClearWorkList (void)
void AddNewRecords (void)
void AddNotListed (void)
void BuildNewRecordsQueries (int recordid, QStringList &from, QStringList &where, MSqlBindings &bindings)
void PruneOverlaps (void)
void BuildListMaps (void)
void ClearListMaps (void)
bool IsBusyRecording (const RecordingInfo *rcinfo)
bool IsSameProgram (const RecordingInfo *a, const RecordingInfo *b) const
bool FindNextConflict (const RecList &cardlist, const RecordingInfo *p, RecConstIter &iter, int openEnd=0) const
const RecordingInfoFindConflict (const RecordingInfo *p, int openEnd=0) const
void MarkOtherShowings (RecordingInfo *p)
void MarkShowingsList (RecList &showinglist, RecordingInfo *p)
void BackupRecStatus (void)
void RestoreRecStatus (void)
bool TryAnotherShowing (RecordingInfo *p, bool samePriority, bool preserveLive=false)
void SchedNewRecords (void)
void MoveHigherRecords (bool move_this=true)
void SchedPreserveLiveTV (void)
void PruneRedundants (void)
void UpdateNextRecord (void)
bool ChangeRecordingEnd (RecordingInfo *oldp, RecordingInfo *newp)
void findAllScheduledPrograms (RecList &proglist)
bool CheckShutdownServer (int prerollseconds, QDateTime &idleSince, bool &blockShutdown)
void ShutdownServer (int prerollseconds, QDateTime &idleSince)
void PutInactiveSlavesToSleep (void)
bool WakeUpSlave (QString slaveHostname, bool setWakingStatus=true)
void WakeUpSlaves (void)
int FillRecordingDir (const QString &title, const QString &hostname, const QString &storagegroup, const QDateTime &recstartts, const QDateTime &recendts, uint cardid, QString &recording_dir, const RecList &reclist)
void FillDirectoryInfoCache (bool force=false)
int CalcTimeToNextHandleRecordingEvent (const QDateTime &curtime, RecConstIter startIter, const RecList &reclist, int prerollseconds, int max_sleep)
void OldRecordedFixups (void)
bool HandleReschedule (void)
bool HandleRunSchedulerStartup (int prerollseconds, int idleWaitForRecordingTime)
void HandleWakeSlave (RecordingInfo &ri, int prerollseconds)
bool HandleRecording (RecordingInfo &ri, bool &statuschanged, int prerollseconds, int tuningTimeout)
void HandleTuning (RecordingInfo &ri, bool &statuschanged, int tuningTimeout)
void HandleRecordingStatusChange (RecordingInfo &ri, RecStatusTypes recStatus, const QString &details)
void HandleIdleShutdown (bool &blockShutdown, QDateTime &idleSince, int prerollseconds, int idleTimeoutSecs, int idleWaitForRecordingTime, bool &statuschanged)

Private Attributes

QString recordTable
QString priorityTable
MythDeque< int > reschedQueue
QMutex schedLock
QMutex recordmatchLock
QWaitCondition reschedWait
RecList reclist
RecList worklist
RecList retrylist
RecList conflictlist
QMap< int, RecListrecordidlistmap
QMap< QString, RecListtitlelistmap
InputGroupMap igrp
QDateTime schedTime
bool reclist_changed
bool specsched
bool schedMoveHigher
bool schedulingEnabled
QMap< int, boolschedAfterStartMap
QMap< int, EncoderLink * > * m_tvList
AutoExpirem_expirer
QMap< QString, boolrecPendingList
bool doRun
MainServerm_mainServer
QMutex resetIdleTime_lock
bool resetIdleTime
bool m_isShuttingDown
MSqlQueryInfo dbConn
QDateTime fsInfoCacheFillTime
QMap< QString, FileSystemInfofsInfoCache
int error
QSet< QString > sysEvents [4]
QDateTime livetvTime
int livetvpriority
int prefinputpri
QMap< QString, boolhasLaterList
IsSameCacheType cache_is_same_program

Detailed Description

Definition at line 32 of file scheduler.h.


Member Typedef Documentation

typedef pair<const RecordingInfo*,const RecordingInfo*> Scheduler::IsSameKey [private]

Definition at line 219 of file scheduler.h.

typedef QMap<IsSameKey,bool> Scheduler::IsSameCacheType [private]

Definition at line 220 of file scheduler.h.


Constructor & Destructor Documentation

Scheduler::Scheduler ( bool  runthread,
QMap< int, EncoderLink * > *  tvList,
QString  recordTbl = "record",
Scheduler master_sched = NULL 
)

Definition at line 54 of file scheduler.cpp.

Scheduler::~Scheduler (  ) 

Definition at line 111 of file scheduler.cpp.


Member Function Documentation

void Scheduler::Stop ( void   ) 

Definition at line 141 of file scheduler.cpp.

Referenced by MainServer::Stop().

void Scheduler::Wait ( void   )  [inline]

Definition at line 40 of file scheduler.h.

Referenced by MainServer::Stop().

void Scheduler::SetExpirer ( AutoExpire autoExpirer  )  [inline]

Definition at line 42 of file scheduler.h.

Referenced by run_backend().

void Scheduler::Reschedule ( int  recordid  ) 
void Scheduler::AddRecording ( const RecordingInfo pi  ) 

Definition at line 1611 of file scheduler.cpp.

Referenced by MainServer::customEvent().

void Scheduler::FillRecordListFromDB ( int  recordid = -1  ) 
Parameters:
recordid Record ID of recording that has changed, or -1 if anything might have been changed.

Definition at line 402 of file scheduler.cpp.

Referenced by handle_command(), and MainServer::HandleGetPendingRecordings().

void Scheduler::FillRecordListFromMaster ( void   ) 

Definition at line 475 of file scheduler.cpp.

Referenced by handle_command().

void Scheduler::UpdateRecStatus ( RecordingInfo pginfo  ) 
void Scheduler::UpdateRecStatus ( uint  cardid,
uint  chanid,
const QDateTime &  startts,
RecStatusType  recstatus,
const QDateTime &  recendts 
)

Definition at line 593 of file scheduler.cpp.

bool Scheduler::GetAllPending ( RecList retList  )  const
void Scheduler::GetAllPending ( QStringList &  strList  )  const [virtual]

Implements MythScheduler.

Definition at line 1564 of file scheduler.cpp.

QMap< QString, ProgramInfo * > Scheduler::GetRecording ( void   )  const [virtual]

Implements MythScheduler.

Definition at line 1531 of file scheduler.cpp.

Referenced by MainServer::HandleQueryRecordings().

void Scheduler::getAllScheduled ( QStringList &  strList  ) 

Definition at line 1581 of file scheduler.cpp.

Referenced by MainServer::HandleGetScheduledRecordings().

void Scheduler::getConflicting ( RecordingInfo pginfo,
QStringList &  strlist 
)

Definition at line 1486 of file scheduler.cpp.

Referenced by MainServer::HandleGetConflictingRecordings().

void Scheduler::getConflicting ( RecordingInfo pginfo,
RecList retlist 
)

Definition at line 1502 of file scheduler.cpp.

void Scheduler::PrintList ( bool  onlyFutureRecordings = false  )  [inline]

Definition at line 64 of file scheduler.h.

Referenced by handle_command(), HandleReschedule(), and PrintList().

void Scheduler::PrintList ( RecList list,
bool  onlyFutureRecordings = false 
)

Definition at line 488 of file scheduler.cpp.

void Scheduler::PrintRec ( const RecordingInfo p,
const char *  prefix = NULL 
)

Definition at line 516 of file scheduler.cpp.

Referenced by MoveHigherRecords(), PrintList(), SchedNewRecords(), and TryAnotherShowing().

void Scheduler::SetMainServer ( MainServer ms  ) 

Definition at line 148 of file scheduler.cpp.

Referenced by MainServer::MainServer(), and MainServer::Stop().

void Scheduler::SlaveConnected ( RecordingList slavelist  ) 

Definition at line 699 of file scheduler.cpp.

Referenced by MainServer::HandleAnnounce().

void Scheduler::SlaveDisconnected ( uint  cardid  ) 

Definition at line 771 of file scheduler.cpp.

Referenced by MainServer::HandleSlaveDisconnectedEvent().

void Scheduler::DisableScheduling ( void   )  [inline]

Definition at line 74 of file scheduler.h.

Referenced by run_backend().

void Scheduler::EnableScheduling ( void   )  [inline]

Definition at line 75 of file scheduler.h.

void Scheduler::GetNextLiveTVDir ( uint  cardid  ) 

Definition at line 4294 of file scheduler.cpp.

Referenced by MainServer::customEvent().

void Scheduler::ResetIdleTime ( void   ) 

Definition at line 153 of file scheduler.cpp.

Referenced by MainServer::customEvent().

bool Scheduler::WasStartedAutomatically (  ) 

Definition at line 4895 of file scheduler.cpp.

Referenced by HandleRunSchedulerStartup().

RecStatusType Scheduler::GetRecStatus ( const ProgramInfo pginfo  ) 

Definition at line 1547 of file scheduler.cpp.

Referenced by MainServer::customEvent().

int Scheduler::GetError ( void   )  const [inline]

Definition at line 83 of file scheduler.h.

Referenced by run_backend().

void Scheduler::run ( void   )  [protected, virtual]

Run's the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.

Note:
If you override this method you must call RunProlog before you do any work and RunEpilog before you exit the run method.

Reimplemented from MThread.

Definition at line 1733 of file scheduler.cpp.

bool Scheduler::VerifyCards ( void   )  [private]

Definition at line 160 of file scheduler.cpp.

Referenced by Scheduler().

bool Scheduler::FillRecordList ( void   )  [private]

Definition at line 352 of file scheduler.cpp.

Referenced by FillRecordListFromDB(), and HandleReschedule().

void Scheduler::UpdateMatches ( int  recordid  )  [private]

Definition at line 3243 of file scheduler.cpp.

Referenced by FillRecordListFromDB(), and HandleReschedule().

void Scheduler::UpdateManuals ( int  recordid  )  [private]

Definition at line 3014 of file scheduler.cpp.

Referenced by BuildNewRecordsQueries().

void Scheduler::BuildWorkList ( void   )  [private]

Definition at line 794 of file scheduler.cpp.

Referenced by FillRecordList().

bool Scheduler::ClearWorkList ( void   )  [private]

Definition at line 808 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::AddNewRecords ( void   )  [private]

Definition at line 3420 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::AddNotListed ( void   )  [private]

Definition at line 3981 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::BuildNewRecordsQueries ( int  recordid,
QStringList &  from,
QStringList &  where,
MSqlBindings bindings 
) [private]

Definition at line 3113 of file scheduler.cpp.

Referenced by UpdateMatches().

void Scheduler::PruneOverlaps ( void   )  [private]

Definition at line 856 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::BuildListMaps ( void   )  [private]

Definition at line 880 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::ClearListMaps ( void   )  [private]

Definition at line 898 of file scheduler.cpp.

Referenced by FillRecordList().

bool Scheduler::IsBusyRecording ( const RecordingInfo rcinfo  )  [private]

Definition at line 1650 of file scheduler.cpp.

Referenced by HandleRecording().

bool Scheduler::IsSameProgram ( const RecordingInfo a,
const RecordingInfo b 
) const [private]

Definition at line 906 of file scheduler.cpp.

Referenced by MarkShowingsList(), and TryAnotherShowing().

bool Scheduler::FindNextConflict ( const RecList cardlist,
const RecordingInfo p,
RecConstIter iter,
int  openEnd = 0 
) const [private]

Definition at line 922 of file scheduler.cpp.

Referenced by FindConflict(), getConflicting(), MoveHigherRecords(), and TryAnotherShowing().

const RecordingInfo * Scheduler::FindConflict ( const RecordingInfo p,
int  openEnd = 0 
) const [private]

Definition at line 1004 of file scheduler.cpp.

Referenced by SchedNewRecords(), and TryAnotherShowing().

void Scheduler::MarkOtherShowings ( RecordingInfo p  )  [private]

Definition at line 1015 of file scheduler.cpp.

Referenced by MoveHigherRecords(), SchedNewRecords(), and TryAnotherShowing().

void Scheduler::MarkShowingsList ( RecList showinglist,
RecordingInfo p 
) [private]

Definition at line 1036 of file scheduler.cpp.

Referenced by MarkOtherShowings().

void Scheduler::BackupRecStatus ( void   )  [private]

Definition at line 1063 of file scheduler.cpp.

Referenced by MoveHigherRecords().

void Scheduler::RestoreRecStatus ( void   )  [private]

Definition at line 1073 of file scheduler.cpp.

Referenced by MoveHigherRecords().

bool Scheduler::TryAnotherShowing ( RecordingInfo p,
bool  samePriority,
bool  preserveLive = false 
) [private]

Definition at line 1083 of file scheduler.cpp.

Referenced by MoveHigherRecords().

void Scheduler::SchedNewRecords ( void   )  [private]

Definition at line 1207 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::MoveHigherRecords ( bool  move_this = true  )  [private]

Definition at line 1280 of file scheduler.cpp.

Referenced by SchedNewRecords(), and SchedPreserveLiveTV().

void Scheduler::SchedPreserveLiveTV ( void   )  [private]

Definition at line 4841 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::PruneRedundants ( void   )  [private]

Definition at line 1343 of file scheduler.cpp.

Referenced by FillRecordList().

void Scheduler::UpdateNextRecord ( void   )  [private]

Definition at line 1419 of file scheduler.cpp.

Referenced by HandleRecordingStatusChange(), and HandleReschedule().

bool Scheduler::ChangeRecordingEnd ( RecordingInfo oldp,
RecordingInfo newp 
) [private]

Definition at line 643 of file scheduler.cpp.

Referenced by AddNewRecords().

void Scheduler::findAllScheduledPrograms ( RecList proglist  )  [private]

Definition at line 4130 of file scheduler.cpp.

Referenced by getAllScheduled().

bool Scheduler::CheckShutdownServer ( int  prerollseconds,
QDateTime &  idleSince,
bool blockShutdown 
) [private]

Definition at line 2634 of file scheduler.cpp.

Referenced by HandleIdleShutdown().

void Scheduler::ShutdownServer ( int  prerollseconds,
QDateTime &  idleSince 
) [private]

Definition at line 2690 of file scheduler.cpp.

Referenced by HandleIdleShutdown().

void Scheduler::PutInactiveSlavesToSleep ( void   )  [private]

Definition at line 2782 of file scheduler.cpp.

Referenced by run().

bool Scheduler::WakeUpSlave ( QString  slaveHostname,
bool  setWakingStatus = true 
) [private]

Definition at line 2932 of file scheduler.cpp.

Referenced by HandleWakeSlave(), and WakeUpSlaves().

void Scheduler::WakeUpSlaves ( void   )  [private]

Definition at line 2983 of file scheduler.cpp.

Referenced by Scheduler().

int Scheduler::FillRecordingDir ( const QString &  title,
const QString &  hostname,
const QString &  storagegroup,
const QDateTime &  recstartts,
const QDateTime &  recendts,
uint  cardid,
QString &  recording_dir,
const RecList reclist 
) [private]

Definition at line 4320 of file scheduler.cpp.

Referenced by GetNextLiveTVDir(), and HandleRecording().

void Scheduler::FillDirectoryInfoCache ( bool  force = false  )  [private]

Definition at line 4813 of file scheduler.cpp.

Referenced by FillRecordingDir().

int Scheduler::CalcTimeToNextHandleRecordingEvent ( const QDateTime &  curtime,
RecConstIter  startIter,
const RecList reclist,
int  prerollseconds,
int  max_sleep 
) [private]

Definition at line 1911 of file scheduler.cpp.

Referenced by run().

void Scheduler::OldRecordedFixups ( void   )  [private]

Definition at line 1693 of file scheduler.cpp.

Referenced by run().

bool Scheduler::HandleReschedule ( void   )  [private]

Definition at line 1977 of file scheduler.cpp.

Referenced by run().

bool Scheduler::HandleRunSchedulerStartup ( int  prerollseconds,
int  idleWaitForRecordingTime 
) [private]

Definition at line 2084 of file scheduler.cpp.

Referenced by run().

void Scheduler::HandleWakeSlave ( RecordingInfo ri,
int  prerollseconds 
) [private]

Definition at line 2134 of file scheduler.cpp.

Referenced by run().

bool Scheduler::HandleRecording ( RecordingInfo ri,
bool statuschanged,
int  prerollseconds,
int  tuningTimeout 
) [private]

Definition at line 2238 of file scheduler.cpp.

Referenced by run().

void Scheduler::HandleTuning ( RecordingInfo ri,
bool statuschanged,
int  tuningTimeout 
) [private]

Definition at line 2457 of file scheduler.cpp.

Referenced by HandleRecording().

void Scheduler::HandleRecordingStatusChange ( RecordingInfo ri,
RecStatusTypes  recStatus,
const QString &  details 
) [private]

Definition at line 2417 of file scheduler.cpp.

Referenced by HandleRecording(), and HandleTuning().

void Scheduler::HandleIdleShutdown ( bool blockShutdown,
QDateTime &  idleSince,
int  prerollseconds,
int  idleTimeoutSecs,
int  idleWaitForRecordingTime,
bool statuschanged 
) [private]

Definition at line 2504 of file scheduler.cpp.

Referenced by run().


Member Data Documentation

QString Scheduler::recordTable [private]
QString Scheduler::priorityTable [private]

Definition at line 90 of file scheduler.h.

Referenced by AddNewRecords(), and Scheduler().

QMutex Scheduler::schedLock [mutable, private]
QMutex Scheduler::recordmatchLock [private]

Definition at line 172 of file scheduler.h.

Referenced by FillRecordListFromDB(), and HandleReschedule().

QWaitCondition Scheduler::reschedWait [private]

Definition at line 173 of file scheduler.h.

Referenced by AddRecording(), Reschedule(), run(), Scheduler(), Stop(), UpdateRecStatus(), and ~Scheduler().

Definition at line 177 of file scheduler.h.

Referenced by BuildListMaps(), ClearListMaps(), FindConflict(), and MoveHigherRecords().

QMap<int, RecList> Scheduler::recordidlistmap [private]

Definition at line 178 of file scheduler.h.

Referenced by BuildListMaps(), ClearListMaps(), MarkOtherShowings(), and TryAnotherShowing().

QMap<QString, RecList> Scheduler::titlelistmap [private]

Definition at line 179 of file scheduler.h.

Referenced by BuildListMaps(), ClearListMaps(), and MarkOtherShowings().

Definition at line 180 of file scheduler.h.

Referenced by FindNextConflict(), IsBusyRecording(), and TryAnotherShowing().

QDateTime Scheduler::schedTime [private]

Definition at line 185 of file scheduler.h.

Referenced by AddNewRecords(), ChangeRecordingEnd(), and UpdateNextRecord().

Definition at line 186 of file scheduler.h.

Referenced by FillRecordList(), and MoveHigherRecords().

Definition at line 187 of file scheduler.h.

Referenced by DisableScheduling(), EnableScheduling(), and HandleRecording().

QMap<int, bool> Scheduler::schedAfterStartMap [private]

Definition at line 188 of file scheduler.h.

Referenced by AddNewRecords(), and HandleRecordingStatusChange().

QMap<int, EncoderLink *>* Scheduler::m_tvList [private]

Definition at line 191 of file scheduler.h.

Referenced by FillRecordingDir(), GetNextLiveTVDir(), HandleRecording(), and SetExpirer().

QMap<QString, bool> Scheduler::recPendingList [private]

Definition at line 195 of file scheduler.h.

Referenced by AddNewRecords(), run(), Scheduler(), Stop(), and ~Scheduler().

Definition at line 199 of file scheduler.h.

Referenced by HandleIdleShutdown(), and ResetIdleTime().

Definition at line 200 of file scheduler.h.

Referenced by HandleIdleShutdown(), and ResetIdleTime().

Definition at line 202 of file scheduler.h.

Referenced by HandleIdleShutdown(), and ShutdownServer().

QDateTime Scheduler::fsInfoCacheFillTime [private]

Definition at line 205 of file scheduler.h.

Referenced by FillDirectoryInfoCache(), HandleReschedule(), and Scheduler().

QMap<QString, FileSystemInfo> Scheduler::fsInfoCache [private]

Definition at line 206 of file scheduler.h.

Referenced by FillDirectoryInfoCache(), and FillRecordingDir().

int Scheduler::error [private]

Definition at line 208 of file scheduler.h.

Referenced by GetError(), Scheduler(), and VerifyCards().

QSet<QString> Scheduler::sysEvents[4] [private]

Definition at line 210 of file scheduler.h.

Referenced by HandleWakeSlave().

QDateTime Scheduler::livetvTime [private]

Definition at line 213 of file scheduler.h.

Referenced by HandleRecording(), SchedNewRecords(), and SchedPreserveLiveTV().

Definition at line 214 of file scheduler.h.

Referenced by SchedPreserveLiveTV(), and TryAnotherShowing().

int Scheduler::prefinputpri [private]

Definition at line 215 of file scheduler.h.

Referenced by AddNewRecords(), and TryAnotherShowing().

QMap<QString, bool> Scheduler::hasLaterList [private]

Definition at line 216 of file scheduler.h.

Referenced by HandleRecording(), and TryAnotherShowing().

Definition at line 221 of file scheduler.h.

Referenced by ClearListMaps(), and IsSameProgram().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Mon Feb 6 06:42:18 2012 for MythTV by  doxygen 1.6.3