XDispatch 0.7.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions
xdispatch::native_source Class Reference

Constructs a sourcetype using a dispatch_source_t object as its main source. More...

#include <xdispatch/source.h>

+ Inheritance diagram for xdispatch::native_source:

List of all members.

Public Member Functions

 native_source (dispatch_source_t)
 ~native_source ()

Protected Member Functions

virtual dispatch_source_t native ()
 Overload this method in case you are implementing a sourcetype based on an dispatch_source_t.
void on_resume ()
 Will be called whenever resume() is called on the owning source.
void on_suspend ()
 Will be called whenever suspend() is called on the owning source.
void on_cancel ()
 Will be called when a source is cancelled, is called BEFORE the cancel handler (if any) is executed on the configured queue.
bool propagate_targetqueue () const
 Override this when your sourcetype is using a native dispatch_source_t internally and return true.
virtual void on_source_ready ()
 Will be called whenever the underlying dispatch_source_t object is ready.
void ready (const any &=any())
 This method needs to be called every time your sourcetype is read.

Detailed Description

Constructs a sourcetype using a dispatch_source_t object as its main source.

Remarks:
As soon as you passed a native_source object in order to create an xdispatch::source object, the xdispatch source will modify the context of the dispatch_source_t in order to work properly.

Definition at line 137 of file source.h.


Constructor & Destructor Documentation


Member Function Documentation

virtual dispatch_source_t xdispatch::native_source::native ( ) [protected, virtual]

Overload this method in case you are implementing a sourcetype based on an dispatch_source_t.

This way users can access the native object by using source::native().

By default this is returning NULL

Reimplemented from xdispatch::sourcetype.

void xdispatch::native_source::on_cancel ( ) [protected, virtual]

Will be called when a source is cancelled, is called BEFORE the cancel handler (if any) is executed on the configured queue.

Override this method to e.g. clean up some resources before the cancel handler is called

Reimplemented from xdispatch::sourcetype.

void xdispatch::native_source::on_resume ( ) [protected, virtual]

Will be called whenever resume() is called on the owning source.

The owning source will ensure on_resume() is never called twice, i.e. without a call to to on_cancel() in between. Make sure not to emit any data while your sourcetype is suspended.

Reimplemented from xdispatch::sourcetype.

virtual void xdispatch::native_source::on_source_ready ( ) [protected, virtual]

Will be called whenever the underlying dispatch_source_t object is ready.

By default directly calls ready() on the sourcetype. Override to do some custom processing

void xdispatch::native_source::on_suspend ( ) [protected, virtual]

Will be called whenever suspend() is called on the owning source.

The owning source will ensure on_suspend() is never called twice, i.e. without a call to to on_resume() in between. Make sure not to emit any data while your sourcetype is suspended.

Reimplemented from xdispatch::sourcetype.

bool xdispatch::native_source::propagate_targetqueue ( ) const [protected, virtual]

Override this when your sourcetype is using a native dispatch_source_t internally and return true.

This will cause all calls to target_queue() of the source to be propagated to the dispatch_source_t object returned by native(). The idea is that your source will trigger and your custom handler is executed directly on the target queue. Your custom handler does some preprocessing within the sourcetype and calls ready(). Instead of dispatching another operation on the targetqueue, the source object will execute the user's handler directly, thus reducing the overhead.

Reimplemented from xdispatch::sourcetype.

void xdispatch::sourcetype::ready ( const any = any()) [protected, inherited]

This method needs to be called every time your sourcetype is read.

The passed data can later be obtained in the handler by using source::data()


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

Generated on Sun Oct 28 2012 22:12:47 for XDispatch by Doxygen 1.7.6.1
© 2010-2012 MLBA (about | privacy) All Rights reserved.