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

Declares an abstract source type. More...

#include <xdispatch/source.h>

+ Inheritance diagram for xdispatch::sourcetype:

List of all members.

Public Member Functions

virtual ~sourcetype ()

Protected Member Functions

 sourcetype ()
void ready (const any &=any())
 This method needs to be called every time your sourcetype is read.
virtual dispatch_source_t native ()
 Overload this method in case you are implementing a sourcetype based on an dispatch_source_t.
virtual 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.
virtual void on_resume ()
 Will be called whenever resume() is called on the owning source.
virtual void on_suspend ()
 Will be called whenever suspend() is called on the owning source.
virtual bool propagate_targetqueue () const
 Override this when your sourcetype is using a native dispatch_source_t internally and return true.

Detailed Description

Declares an abstract source type.

Subclass this type to implement custom source types. Whenever your type becomes ready and the source should dispatch the handler, simply call ready() with some data you want to make available via source::data() to your handler

Definition at line 50 of file source.h.


Constructor & Destructor Documentation

virtual xdispatch::sourcetype::~sourcetype ( ) [virtual]

Member Function Documentation

virtual dispatch_source_t xdispatch::sourcetype::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 in xdispatch::native_source.

virtual void xdispatch::sourcetype::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 in xdispatch::native_source.

virtual void xdispatch::sourcetype::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 in xdispatch::native_source.

virtual void xdispatch::sourcetype::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 in xdispatch::native_source.

virtual bool xdispatch::sourcetype::propagate_targetqueue ( ) const [inline, 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 in xdispatch::native_source.

Definition at line 116 of file source.h.

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

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 Jan 27 2013 21:21:52 for XDispatch by Doxygen 1.7.6.1
© 2010-2013 MLBA (about | privacy) All Rights reserved.