Honeycomb  0.1
Component-Model Framework
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
honey::PeriodicTask Class Referenceabstract

Base class of PeriodicTask_, returned by scheduler. More...

#include <PeriodicTask.h>

Inheritance diagram for honey::PeriodicTask:
Inheritance graph
[legend]
Collaboration diagram for honey::PeriodicTask:
Collaboration graph
[legend]

Classes

struct  Cancelled
 Future result when cancelled. More...
 

Public Types

typedef SharedPtr< PeriodicTaskPtr
 
typedef function< void()> Func
 

Public Member Functions

virtual ~PeriodicTask ()
 
bool active () const
 Check if task is scheduled or executing. More...
 
MonoClock::Duration delay () const
 Returns time remaining until task is due for execution (task is due at zero time or less) More...
 
void cancel ()
 Unschedule task from further execution. If the task is awaiting execution then its future will throw exception Cancelled. More...
 
void interrupt (const Exception::ConstPtr &e=new thread::Interrupted)
 Request an interrupt in the executing task's thread. More...
 
bool interruptRequested ()
 Check whether an interrupt has been requested for the executing task's thread. More...
 
void setPriority (int priority)
 Set task's thread execution scheduling priority. More...
 
int getPriority () const
 Get task's thread execution scheduling priority. More...
 
const Idid () const
 Get id used for debug output. More...
 
String info () const
 Get task info for prepending to a log record. More...
 
- Public Member Functions inherited from honey::SharedObj< PeriodicTask >
 SharedObj (Alloc &&a=Alloc()) debug_if(
 Construct with allocator that is called to deallocate this shared object when all references have been released. More...
 

Static Public Member Functions

static PeriodicTaskcurrent ()
 Get the current task object. Must be called from a task functor. More...
 

Protected Types

enum  State { State::idle, State::wait, State::exec }
 

Protected Member Functions

 PeriodicTask (PeriodicSched &sched, optional< MonoClock::Duration > period, optional< MonoClock::Duration > delay, const Id &id)
 
virtual void exec ()=0
 
virtual void readyFunctor (bool reset)=0
 
virtual void cancelFunctor ()=0
 
void operator() ()
 
virtual void trace (const String &file, int line, const String &msg) const
 
virtual bool traceEnabled () const
 
- Protected Member Functions inherited from honey::SharedObj< PeriodicTask >
void finalize ()
 Destroys object. Called when strong reference count reaches 0. May be overridden to prevent destruction. More...
 

Protected Attributes

PeriodicSched_sched
 
optional< MonoClock::Duration_period
 
optional< MonoClock::Duration_delay
 
Id _id
 
Mutex _lock
 
Ptr _self
 
Atomic< State_state
 
Atomic< MonoClock::TimePoint_due
 
bool _cancelled
 
Thread_thread
 
int _priority
 

Friends

class PeriodicSched
 
struct mt::Funcptr< void()>
 

Detailed Description

Base class of PeriodicTask_, returned by scheduler.

See also
PeriodicSched

Member Typedef Documentation

typedef function<void ()> honey::PeriodicTask::Func

Member Enumeration Documentation

enum honey::PeriodicTask::State
strongprotected
Enumerator
idle 

Not active.

wait 

Waiting for next period.

exec 

Executing functor.

Constructor & Destructor Documentation

virtual honey::PeriodicTask::~PeriodicTask ( )
inlinevirtual
honey::PeriodicTask::PeriodicTask ( PeriodicSched sched,
optional< MonoClock::Duration period,
optional< MonoClock::Duration delay,
const Id id 
)
protected

Member Function Documentation

bool honey::PeriodicTask::active ( ) const
inline

Check if task is scheduled or executing.

void honey::PeriodicTask::cancel ( )

Unschedule task from further execution. If the task is awaiting execution then its future will throw exception Cancelled.

virtual void honey::PeriodicTask::cancelFunctor ( )
protectedpure virtual
PeriodicTask & honey::PeriodicTask::current ( )
static

Get the current task object. Must be called from a task functor.

MonoClock::Duration honey::PeriodicTask::delay ( ) const
inline

Returns time remaining until task is due for execution (task is due at zero time or less)

virtual void honey::PeriodicTask::exec ( )
protectedpure virtual
int honey::PeriodicTask::getPriority ( ) const
inline

Get task's thread execution scheduling priority.

See also
Thread::getPriority()
const Id& honey::PeriodicTask::id ( ) const
inline

Get id used for debug output.

String honey::PeriodicTask::info ( ) const

Get task info for prepending to a log record.

void honey::PeriodicTask::interrupt ( const Exception::ConstPtr &  e = new thread::Interrupted)
inline

Request an interrupt in the executing task's thread.

See also
Thread::interrupt()
bool honey::PeriodicTask::interruptRequested ( )
inline

Check whether an interrupt has been requested for the executing task's thread.

void honey::PeriodicTask::operator() ( )
protected
virtual void honey::PeriodicTask::readyFunctor ( bool  reset)
protectedpure virtual
void honey::PeriodicTask::setPriority ( int  priority)
inline

Set task's thread execution scheduling priority.

See also
Thread::setPriority()
void honey::PeriodicTask::trace ( const String file,
int  line,
const String msg 
) const
protectedvirtual

Reimplemented from honey::thread::Pool::Task.

bool honey::PeriodicTask::traceEnabled ( ) const
inlineprotectedvirtual

Reimplemented from honey::thread::Pool::Task.

Friends And Related Function Documentation

friend struct mt::Funcptr< void()>
friend
friend class PeriodicSched
friend

Member Data Documentation

bool honey::PeriodicTask::_cancelled
protected
optional<MonoClock::Duration> honey::PeriodicTask::_delay
protected
Atomic<MonoClock::TimePoint> honey::PeriodicTask::_due
protected
Id honey::PeriodicTask::_id
protected
Mutex honey::PeriodicTask::_lock
protected
optional<MonoClock::Duration> honey::PeriodicTask::_period
protected
int honey::PeriodicTask::_priority
protected
PeriodicSched& honey::PeriodicTask::_sched
protected
Ptr honey::PeriodicTask::_self
protected
Atomic<State> honey::PeriodicTask::_state
protected
Thread* honey::PeriodicTask::_thread
protected

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