libXDispatch 0.4
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...

List of all members.

Public Member Functions

 timer (uint64_t interval, const xdispatch::queue &target=global_queue())
 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 stop ()
 Will stop the timer.
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 set_queue (const xdispatch::queue &)
 Sets the queue the handler will be executed on.
xdispatch::queue queue ()
virtual const dispatch_source_t native () const

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.

Constructor & Destructor Documentation

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

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
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
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::handler ( dispatch_block_t  )

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

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.

virtual const dispatch_source_t xdispatch::timer::native ( ) const [virtual]
Returns:
The native dispatch_source_t associated with the timer
xdispatch::queue xdispatch::timer::queue ( )
Returns:
the queue the handler will be executed on
void xdispatch::timer::set_queue ( const xdispatch::queue )

Sets the queue the handler will be executed on.

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 ( 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 ,
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 ,
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().
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().

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

Generated on Wed Feb 22 2012 19:51:17 for libXDispatch by Doxygen 1.7.4
Content © 2011-2012 MLBA (about | privacy) – Design © 2010-2012 Emzeat. All Rights reserved.