#include <service.h>
Data Structures | |
struct | queue_item |
Public Member Functions | |
virtual | ~at_service () |
at_service () | |
void | register_job (const time_value &when, at_job *jp) |
void | register_job_delta (const time_value &seconds, at_job *jp) |
void | unregister_job (at_job *jp) |
time_value | get_maximum_sleep () const |
void | process () |
bool | empty () const |
Private Types | |
typedef std::deque< queue_item > | queue_t |
Private Member Functions | |
at_service (const at_service &) | |
at_service & | operator= (const at_service &) |
Private Attributes | |
queue_t | queue |
The plumbing::at_service class is used to represent a service that runs jobs at a specific time.
Definition at line 38 of file service.h.
typedef std::deque<queue_item> plumbing::at_service::queue_t [private] |
plumbing::at_service::~at_service | ( | ) | [virtual] |
The destructor.
Definition at line 24 of file service.cc.
plumbing::at_service::at_service | ( | ) |
The default constructor.
Definition at line 33 of file service.cc.
plumbing::at_service::at_service | ( | const at_service & | ) | [private] |
The copy constructor. Do not use.
bool plumbing::at_service::empty | ( | ) | const [inline] |
plumbing::time_value plumbing::at_service::get_maximum_sleep | ( | ) | const |
The get_maximum_sleep is used to obtain a sleep time, for handing to select(), based on the jobs in the queue. If there are no jobs, 60 seconds will be returned.
Definition at line 98 of file service.cc.
at_service& plumbing::at_service::operator= | ( | const at_service & | ) | [private] |
The assignment operator. Do not use.
void plumbing::at_service::process | ( | ) |
The process method will examine all of the jobs in the queue, and run all which have reached or passed their stated execution time. Jobs are removed from the queue when they are run, but they are NOT deleted.
If a job wishes to run again, it is safe to call, and it should call, the at_service::register_job within its at_job::process method. It is also safe if jobs use "delete this" within their at_job::process method.
Definition at line 117 of file service.cc.
void plumbing::at_service::register_job | ( | const time_value & | when, | |
at_job * | jp | |||
) |
The register_job method is used to add a jobs to the queue of jobs waiting to run.
when | The time the job is to be called. | |
jp | The job to be queued. |
Definition at line 46 of file service.cc.
void plumbing::at_service::register_job_delta | ( | const time_value & | seconds, | |
at_job * | jp | |||
) |
The The register_job_delta method is used to add a jobs to the queue of jobs waiting to run.
seconds | How many seconds into the future the job is to be called. | |
jp | The job to be queued. |
Definition at line 39 of file service.cc.
void plumbing::at_service::unregister_job | ( | at_job * | jp | ) |
The unregister_job method is used to remove a job from the queue of jobs waiting to run.
jp | The job to be de-queued. |
Definition at line 75 of file service.cc.
queue_t plumbing::at_service::queue [private] |