plumbing::at_service Class Reference

#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_itemqueue_t

Private Member Functions

 at_service (const at_service &)
at_serviceoperator= (const at_service &)

Private Attributes

queue_t queue

Detailed Description

The plumbing::at_service class is used to represent a service that runs jobs at a specific time.

Note:
There is no provision for multi-threading in this code. The assumption is that all activity is initiated by the plumbing::reactor::process loop.

Definition at line 38 of file service.h.


Member Typedef Documentation

typedef std::deque<queue_item> plumbing::at_service::queue_t [private]

Definition at line 118 of file service.h.


Constructor & Destructor Documentation

virtual plumbing::at_service::~at_service (  )  [virtual]

The destructor.

plumbing::at_service::at_service (  ) 

The default constructor.

plumbing::at_service::at_service ( const at_service  )  [private]

The copy constructor. Do not use.


Member Function Documentation

bool plumbing::at_service::empty (  )  const [inline]

The empty method is used to determine whether or not the at service still has work to do.

Returns:
true if no jobs queued, false if there is still work to be done.

Definition at line 109 of file service.h.

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.

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.

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.

Parameters:
when The time the job is to be called.
jp The job to be queued.
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.

Parameters:
seconds How many seconds into the future the job is to be called.
jp The job to be queued.
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.

Parameters:
jp The job to be de-queued.

Field Documentation

The queue instance variable is used to remember the jobs waiting to run.

Definition at line 124 of file service.h.


The documentation for this class was generated from the following file:
Generated on Thu Sep 16 14:32:12 2010 for Plumbing by  doxygen 1.6.3