Provides a timer executing a block or an operation on a specific queue when a timeout occurs. More...
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 timer * | current () |
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. |
Provides a timer executing a block or an operation on a specific queue when a timeout occurs.
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
interval | The interval in nanoseconds at which the timer will fire after the timeout occured. |
target | The 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 | ( | ) |
static timer* xdispatch::timer::current | ( | ) | [static] |
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.
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] |
xdispatch::queue xdispatch::timer::queue | ( | ) |
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 | ( | ) |
void xdispatch::timer::stop | ( | ) |