Provides a source implementation. More...
#include <xdispatch/source.h>
Public Member Functions | |
source (sourcetype *) | |
Creates a new source waiting for the given source type. | |
~source () | |
void | resume () |
Resumes the invocation of operations or blocks assigned to the object. | |
void | suspend () |
Suspends the invocation of operations or blocks assigned to the object. | |
void | handler (xdispatch::operation *) |
Sets the handler to dispatch each time the source becomes ready. | |
virtual void | handler (dispatch_block_t b) |
Sets the handler to dispatch each time the source becomes ready. | |
void | target_queue (const xdispatch::queue &) |
Sets the queue the handler will be executed on. | |
xdispatch::queue | target_queue () const |
virtual dispatch_object_t | native () const |
dispatch_source_t | native_source () const |
void | cancel () |
Asynchronously cancels the dispatch source, preventing any further invocation of its event handler block. | |
void | cancel_handler (xdispatch::operation *) |
Sets the cancellation handler block for the given dispatch source. | |
virtual void | cancel_handler (dispatch_block_t b) |
Sets the cancellation handler block for the given dispatch source. | |
bool | operator== (const object &) |
bool | operator== (const dispatch_object_t &) |
bool | operator!= (const object &) |
bool | operator!= (const dispatch_object_t &) |
Static Public Member Functions | |
template<typename T > | |
static T | data () |
Provides a source implementation.
A dispatch source will wait for a specific ressource or operation (as defined by the given type) to complete and dispatch a given handler on completion.
Construct a new source using a specific sourcetype to define the events the source will fire at.
Creates a new source waiting for the given source type.
void xdispatch::source::cancel | ( | ) |
Asynchronously cancels the dispatch source, preventing any further invocation of its event handler block.
Cancellation prevents any further invocation of the event handler block for the specified dispatch source, but does not interrupt an event handler block that is already in progress. The optional cancellation handler is submitted to the target queue once the event handler block has been completed.
The cancellation handler is submitted to the source's target queue when the source's event handler has finished, indicating that it is safe to close the source's handle (e.g. file descriptor or mach port if any).
The optional cancellation handler is submitted to the xdispatch::source object's target queue only after the system has released all of its references to any underlying system objects (file descriptors or mach ports). Thus, the cancellation handler is a convenient place to close or deallocate such system objects.
Sets the cancellation handler block for the given dispatch source.
The cancellation handler (if specified) is submitted to the source's target queue in response to a call to dispatch_source_cancel when the system has released all references to the source's underlying handle and the source's event handler block has returned.
virtual void xdispatch::source::cancel_handler | ( | dispatch_block_t | b | ) | [inline, virtual] |
Sets the cancellation handler block for the given dispatch source.
The cancellation handler (if specified) is submitted to the source's target queue in response to a call to dispatch_source_cancel when the system has released all references to the source's underlying handle and the source's event handler block has returned.
static T xdispatch::source::data | ( | ) | [inline, static] |
Pass the type of the data to retrieve as template parameter. If the requested datatype cannot be provided, a bad_cast exception will be thrown.
void xdispatch::source::handler | ( | xdispatch::operation * | ) |
Sets the handler to dispatch each time the source becomes ready.
You can use data() to obtain a pointer to data provided by the source and possibly being the reason for the handler to be dispatched.
virtual void xdispatch::source::handler | ( | dispatch_block_t | b | ) | [inline, virtual] |
virtual dispatch_object_t xdispatch::source::native | ( | ) | const [virtual] |
Implements xdispatch::object.
bool xdispatch::object::operator!= | ( | const object & | ) | [inherited] |
bool xdispatch::object::operator!= | ( | const dispatch_object_t & | ) | [inherited] |
bool xdispatch::object::operator== | ( | const object & | ) | [inherited] |
bool xdispatch::object::operator== | ( | const dispatch_object_t & | ) | [inherited] |
void xdispatch::source::resume | ( | ) | [virtual] |
Resumes the invocation of operations or blocks assigned to the object.
Reimplemented from xdispatch::object.
void xdispatch::source::suspend | ( | ) | [virtual] |
Suspends the invocation of operations or blocks assigned to the object.
The object will be suspended as soon as the currently executed operation or block finished.
Reimplemented from xdispatch::object.
void xdispatch::source::target_queue | ( | const xdispatch::queue & | ) | [virtual] |
Sets the queue the handler will be executed on.
Reimplemented from xdispatch::object.