BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
Scheduler Class Reference

#include <Scheduler.h>

+ Inheritance diagram for Scheduler:

Public Member Functions

 Scheduler ()
 
 ~Scheduler ()
 
void schedule (double deltaT, ScheduledEvent *event)
 
void start ()
 
void stop ()
 
bool running ()
 
void clear ()
 
GPStime elapsed_time () const
 
void setLog (std::ostream &out)
 
void endLogging ()
 
void printOn (std::ostream &out) const
 
 Scheduler ()
 
 ~Scheduler ()
 
void schedule (double deltaT, ScheduledEvent *event)
 
void start ()
 
void stop ()
 
bool running ()
 
void clear ()
 
GPStime elapsed_time () const
 
void setLog (std::ostream &out)
 
void endLogging ()
 
void printOn (std::ostream &out) const
 

Static Public Member Functions

static Schedulerinstance ()
 
static Schedulerinstance ()
 

Detailed Description

Constructor & Destructor Documentation

◆ Scheduler() [1/2]

Scheduler::Scheduler ( )

Definition at line 11 of file Scheduler.cxx.

12: m_time(GPStime(0))
13, m_running(false)
14, m_log(0)
15{
16 assert( s_instance==0); // require only one
17 s_instance = this;
18}

Referenced by instance().

◆ ~Scheduler() [1/2]

Scheduler::~Scheduler ( )

Definition at line 20 of file Scheduler.cxx.

21{
22 clear();
23}
void clear()
Definition: Scheduler.cxx:24

◆ Scheduler() [2/2]

Scheduler::Scheduler ( )

◆ ~Scheduler() [2/2]

Scheduler::~Scheduler ( )

Member Function Documentation

◆ clear() [1/2]

void Scheduler::clear ( )

Definition at line 24 of file Scheduler.cxx.

25{
26 while( ! empty() ) {
27 iterator f = begin();
28 delete (*f).second;
29 erase(f);
30 }
31 m_time = 0;
32}

Referenced by ~Scheduler().

◆ clear() [2/2]

void Scheduler::clear ( )

◆ elapsed_time() [1/2]

GPStime Scheduler::elapsed_time ( ) const
inline

Definition at line 61 of file Calibration/facilities/facilities-00-00-04/facilities/Scheduler.h.

61{return m_time;}

Referenced by printOn(), and setLog().

◆ elapsed_time() [2/2]

GPStime Scheduler::elapsed_time ( ) const
inline

Definition at line 61 of file InstallArea/include/facilities/facilities/Scheduler.h.

61{return m_time;}

◆ endLogging() [1/2]

void Scheduler::endLogging ( )

Definition at line 86 of file Scheduler.cxx.

87{
88 m_log = 0;
89}

◆ endLogging() [2/2]

void Scheduler::endLogging ( )

◆ instance() [1/2]

Scheduler * Scheduler::instance ( )
static

Definition at line 9 of file Scheduler.cxx.

9{return (s_instance) ? s_instance : new Scheduler();}

Referenced by ScheduledEvent::schedule().

◆ instance() [2/2]

static Scheduler * Scheduler::instance ( )
static

◆ printOn() [1/2]

void Scheduler::printOn ( std::ostream &  out) const

Definition at line 66 of file Scheduler.cxx.

67{
68 out << "\nScheduler stack: current time = " << elapsed_time() << std::endl;
69 out << "\ttime\tclass name\n";
70 for( const_iterator it= begin(); it !=end(); ++it){
71 std::pair<double, ScheduledEvent*> entry = *it;
72 out << "\t" << entry.first << '\t' << entry.second->name() << std::endl ;
73 }
74 out << std::endl;
75
76}

◆ printOn() [2/2]

void Scheduler::printOn ( std::ostream &  out) const

◆ running() [1/2]

bool Scheduler::running ( )
inline

Definition at line 55 of file Calibration/facilities/facilities-00-00-04/facilities/Scheduler.h.

55{return m_running;}

◆ running() [2/2]

bool Scheduler::running ( )
inline

Definition at line 55 of file InstallArea/include/facilities/facilities/Scheduler.h.

55{return m_running;}

◆ schedule() [1/2]

void Scheduler::schedule ( double  deltaT,
ScheduledEvent event 
)

Definition at line 35 of file Scheduler.cxx.

36{
37 insert(std::make_pair(m_time+deltaT, event));
38}

Referenced by ScheduledEvent::schedule().

◆ schedule() [2/2]

void Scheduler::schedule ( double  deltaT,
ScheduledEvent event 
)

◆ setLog() [1/2]

void Scheduler::setLog ( std::ostream &  out)

Definition at line 78 of file Scheduler.cxx.

79{
80 m_log = &out;
81 out << "\nSchedule event: current time = " << elapsed_time() << std::endl;
82 out << "\ttime\tEvent\n";
83
84}

◆ setLog() [2/2]

void Scheduler::setLog ( std::ostream &  out)

◆ start() [1/2]

void Scheduler::start ( )

Definition at line 40 of file Scheduler.cxx.

41{
42 m_running = true;
43
44 while( !empty() && m_running ) {
45
46 // get the entry at the head of the queue
47 std::pair<double, ScheduledEvent*> entry = *begin();
48
49 // set current time, remove the entry
50 m_time = entry.first;
51 erase(begin());
52
53 // run, then delete it
54 if( m_log ) {
55 (*m_log) << "\t" << entry.first << '\t' << entry.second->name() << std::endl ;
56 }
57 entry.second->execute();
58 delete entry.second;
59 }
60}

◆ start() [2/2]

void Scheduler::start ( )

◆ stop() [1/2]

void Scheduler::stop ( )

Definition at line 62 of file Scheduler.cxx.

63{
64 m_running = false;
65}

◆ stop() [2/2]

void Scheduler::stop ( )

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