XDispatch 0.6.1
Public Member Functions | Static Public Member Functions
xdispatch::timer Class Reference

Provides a timer executing a block or an operation on a specific queue when a timeout occurs. More...

#include <xdispatch/timer.h>

Inheritance diagram for xdispatch::timer:

List of all members.

Public Member Functions

 timer (uint64_t interval, const xdispatch::queue &target=global_queue(), dispatch_time_t starting=DISPATCH_TIME_NOW)
 Constructs a new periodic timer.
 timer (const timer &)
 timer (dispatch_source_t)
 ~timer ()
void interval (uint64_t)
 Use this to set the interval in nanoseconds.
void latency (uint64_t)
 Use this to set the latency in nanoseconds which the timer might be early or late.
void start ()
 Will start the timer.
void resume ()
void stop ()
 Will stop the timer.
void suspend ()
void handler (xdispatch::operation *)
 Sets the operation that will be executed every time the timer fires.
void handler (dispatch_block_t)
 Sets the block that will be executed every time the timer fires.
void target_queue (const xdispatch::queue &)
 Sets the queue the handler will be executed on.
xdispatch::queue target_queue ()
dispatch_object_t native () const
timeroperator= (const timer &)
bool operator== (const object &)
bool operator== (const dispatch_object_t &)
bool operator!= (const object &)
bool operator!= (const dispatch_object_t &)

Static Public Member Functions

static timercurrent ()
static void single_shot (dispatch_time_t, const xdispatch::queue &, xdispatch::operation *)
 Creates a single shot timer executing the given operation on the given queue at the given time.
static void single_shot (struct tm *, const xdispatch::queue &, xdispatch::operation *)
 Creates a single shot timer executing the given operation on the given queue at the given time.
static void single_shot (dispatch_time_t, const xdispatch::queue &, dispatch_block_t)
 Creates a single shot timer executing the given block on the given queue at the given time.
static void single_shot (struct tm *, const xdispatch::queue &, dispatch_block_t)
 Creates a single shot timer executing the given block on the given queue at the given time.

Detailed Description

Provides a timer executing a block or an operation on a specific queue when a timeout occurs.

Remarks:
Although you can get the dispatch_source_t associated with this timer by calling native(), please be aware that as soon as you do any changes to this source not by using the timer object it is not garanteed, that the timer object will still work as expected.

Definition at line 41 of file timer.h.


Constructor & Destructor Documentation

xdispatch::timer::timer ( uint64_t  interval,
const xdispatch::queue target = global_queue(),
dispatch_time_t  starting = DISPATCH_TIME_NOW 
)

Constructs a new periodic timer.

The timer will be stopped, call start() to execute it

Parameters:
intervalThe interval in nanoseconds at which the timer will fire after the timeout occured.
targetThe queue to execute the timer on, defaults to the global_queue
startingThe time at which the timer will fire for the first time
xdispatch::timer::timer ( const timer )
xdispatch::timer::timer ( dispatch_source_t  )
xdispatch::timer::~timer ( )

Member Function Documentation

static timer* xdispatch::timer::current ( ) [static]
Returns:
The timer responsible for the handler to be executed or NULL if the handler was not executed because of a timer firing

Reimplemented in QDispatchTimer.

void xdispatch::timer::handler ( dispatch_block_t  )

Sets the block that will be executed every time the timer fires.

void xdispatch::timer::handler ( xdispatch::operation )

Sets the operation that will be executed every time the timer fires.

As in queues, the timer takes possesion of the operation and will handle deletion. To change this behaviour, set the auto_delete flag of the operation.

See also:
operation::auto_delete();
void xdispatch::timer::interval ( uint64_t  )

Use this to set the interval in nanoseconds.

When called for the first time on a single-shot timer, the timer will be converted to a periodic timer with the given interval.

void xdispatch::timer::latency ( uint64_t  )

Use this to set the latency in nanoseconds which the timer might be early or late.

When not set the latency will be kept as low as possible.

dispatch_object_t xdispatch::timer::native ( ) const [virtual]
Returns:
The native dispatch_source_t associated with the timer

Implements xdispatch::object.

bool xdispatch::object::operator!= ( const dispatch_object_t ) [inherited]
bool xdispatch::object::operator!= ( const object ) [inherited]
timer& xdispatch::timer::operator= ( const timer )
bool xdispatch::object::operator== ( const object ) [inherited]
bool xdispatch::object::operator== ( const dispatch_object_t ) [inherited]
void xdispatch::timer::resume ( ) [virtual]
See also:
start();

Implements xdispatch::object.

static void xdispatch::timer::single_shot ( dispatch_time_t  ,
const xdispatch::queue ,
dispatch_block_t   
) [static]

Creates a single shot timer executing the given block on the given queue at the given time.

This is quite similar to using xdispatch::queue::after()

static void xdispatch::timer::single_shot ( struct tm *  ,
const xdispatch::queue ,
dispatch_block_t   
) [static]

Creates a single shot timer executing the given block on the given queue at the given time.

This is quite similar to using xdispatch::queue::after()

static void xdispatch::timer::single_shot ( dispatch_time_t  ,
const xdispatch::queue ,
xdispatch::operation  
) [static]

Creates a single shot timer executing the given operation on the given queue at the given time.

This is quite similar to using xdispatch::queue::after()

static void xdispatch::timer::single_shot ( struct tm *  ,
const xdispatch::queue ,
xdispatch::operation  
) [static]

Creates a single shot timer executing the given operation on the given queue at the given time.

This is quite similar to using xdispatch::queue::after()

void xdispatch::timer::start ( )

Will start the timer.

Remarks:
A new created timer will be stopped and needs to me started first. Once started, ensure balanced calls between start() and stop().
See also:
resume();

Reimplemented in QDispatchTimer.

void xdispatch::timer::stop ( )

Will stop the timer.

Remarks:
A new created timer will be stopped and needs to me started first. Once started, ensure balanced calls between start() and stop().
See also:
suspend()

Reimplemented in QDispatchTimer.

void xdispatch::timer::suspend ( ) [virtual]
See also:
stop();

Implements xdispatch::object.

xdispatch::queue xdispatch::timer::target_queue ( )
Returns:
the queue the handler will be executed on
void xdispatch::timer::target_queue ( const xdispatch::queue )

Sets the queue the handler will be executed on.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Thu Apr 12 2012 09:50:43 for XDispatch by Doxygen 1.7.4
© 2010-2012 MLBA (about | privacy) All Rights reserved.