XDispatch 0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Slots | Signals | Public Member Functions | Friends
QDispatchGroup Class Reference

A DispatchGroup is a group of QRunnables dispatched on queues. More...

#include <QtDispatch/qdispatchgroup.h>

+ Inheritance diagram for QDispatchGroup:

List of all members.

Public Slots

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.

Signals

void allFinished ()
 This will be emitted additionally to any function or block submitted via notify().

Public Member Functions

 QDispatchGroup ()
 Creates a new QDispatchGroup.
 QDispatchGroup (dispatch_group_t)
 QDispatchGroup (const QDispatchGroup &)
 QDispatchGroup (const xdispatch::group &)
 ~QDispatchGroup ()
void async (QRunnable *r, const xdispatch::queue &q=xdispatch::global_queue())
 Dispatches a Runnable on the given Queue.
bool wait (const QTime &t)
 Waits until the given time has passed or all dispatched runnables in the group were executed.
void notify (QRunnable *r, const xdispatch::queue &=xdispatch::global_queue())
 This function schedules a notification runnable to be submitted to the specified queue once all runnables associated with the dispatch group have completed.
void notify (xdispatch::operation *, const xdispatch::queue &=xdispatch::global_queue())
void notify (dispatch_block_t b, const xdispatch::queue &q=xdispatch::global_queue())
void enableAllFinishedSignal ()
 Activates the allFinished() signal or this QDispatchGroup.
void async (operation *r, const queue &q=global_queue())
 Dispatches an operation on the given Queue.
void async (dispatch_block_t b, const queue &q=global_queue())
 Same as dispatch(operation* r, ...) Will wrap the given block in an operation and put it on the queue.
bool wait (dispatch_time_t t=DISPATCH_TIME_FOREVER)
 Waits until the given time has passed or all dispatched operations in the group were executed.
bool wait (struct tm *timeout)
 Waits until the given time has passed or all dispatched operations in the group were executed.
virtual dispatch_object_t native () const
dispatch_group_t native_group () const
virtual void target_queue (const queue &)
 Sets the target queue of this object, i.e.
bool operator== (const object &)
bool operator== (const dispatch_object_t &)
bool operator!= (const object &)
bool operator!= (const dispatch_object_t &)

Friends

Q_DECL_EXPORT QDebug operator<< (QDebug, const QDispatchGroup &)

Detailed Description

A DispatchGroup is a group of QRunnables dispatched on queues.

This class provides a way to track all these QRunnables and notify you if all of them finished executing.

See also Apple's Documentation of Dispatch Groups

Definition at line 56 of file qdispatchgroup.h.


Constructor & Destructor Documentation

Creates a new QDispatchGroup.


Member Function Documentation

void QDispatchGroup::allFinished ( ) [signal]

This will be emitted additionally to any function or block submitted via notify().

Every time the all work dispatched to the group (i.e. the group is empty) this signal will be emitted.

See also:
enableAllFinishedSignal()
void xdispatch::group::async ( operation r,
const queue q = global_queue() 
) [inherited]

Dispatches an operation on the given Queue.

Parameters:
rThe operation to be dispatched
qThe Queue to use. If no Queue is given, the system default queue will be used
void xdispatch::group::async ( dispatch_block_t  b,
const queue q = global_queue() 
) [inline, inherited]

Same as dispatch(operation* r, ...) Will wrap the given block in an operation and put it on the queue.

Definition at line 73 of file group.h.

void QDispatchGroup::async ( QRunnable *  r,
const xdispatch::queue q = xdispatch::global_queue() 
)

Dispatches a Runnable on the given Queue.

Parameters:
rThe QRunnable to be dispatched
qThe Queue to use. If no Queue is given, the system default queue will be used

Activates the allFinished() signal or this QDispatchGroup.

Needs to be called everytime all scheduled work on the group finished and new work was submitted which was not finished yet.

Note: All installed notification handlers will be disabled and all other QDispatchGroup objects working on the same group will stop to emit the signal, i.e. only one QDispatchGroup object can emit the signal at a time.

Note2: When assigning a new notification handler by using notify() the signal of this object will be enabled by default

virtual dispatch_object_t xdispatch::group::native ( ) const [virtual, inherited]
Returns:
The dispatch_object_t object associated with this C++ object. Use this, if you need to use the plain C Interface of libdispatch.

Implements xdispatch::object.

Returns:
The dispatch_group_t object associated with this C++ object. Use this, if you need to use the plain C Interface of libdispatch.
void QDispatchGroup::notify ( QRunnable *  r,
const xdispatch::queue = xdispatch::global_queue() 
)

This function schedules a notification runnable to be submitted to the specified queue once all runnables associated with the dispatch group have completed.

If no runnables are associated with the dispatch group (i.e. the group is empty) then the notification runnable will be submitted immediately.

The runnable will be empty at the time the notification block is submitted to the target queue. The group may either be deleted or reused for additional operations.

See also:
libdispatch for more information.
See also:
notify(QRunnable* r, const xdispatch::queue&);

Reimplemented from xdispatch::group.

Definition at line 106 of file qdispatchgroup.h.

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 QDispatchGroup::resume ( ) [virtual, slot]

Resumes the invocation of operations or blocks assigned to the object.

Reimplemented from xdispatch::object.

void QDispatchGroup::suspend ( ) [virtual, slot]

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.

Remarks:
Calls to suspend() should be balanced with calls to resume() to continue an object

Reimplemented from xdispatch::object.

virtual void xdispatch::object::target_queue ( const queue ) [virtual, inherited]

Sets the target queue of this object, i.e.

the queue all items concerning this object will be dispatched on in turn.

Remarks:
This has no effect on the global queues and the main queue.

Reimplemented in xdispatch::source.

Waits until the given time has passed or all dispatched operations in the group were executed.

Parameters:
tgive a time here or a DISPATCH_TIME_FOREVER to wait until all operations are done
Returns:
false if the timeout occured or true if all operations were executed
bool QDispatchGroup::wait ( const QTime &  t)

Waits until the given time has passed or all dispatched runnables in the group were executed.

Parameters:
tgive a timeout here or a QTime of zero to wait until all runnables are done
Returns:
false if the timeout occured or true if all runnables were executed
bool xdispatch::group::wait ( struct tm *  timeout) [inherited]

Waits until the given time has passed or all dispatched operations in the group were executed.

Parameters:
timeoutgive a timeout here
Returns:
false if the timeout occured or true if all operations were executed

Friends And Related Function Documentation

Q_DECL_EXPORT QDebug operator<< ( QDebug  ,
const QDispatchGroup  
) [friend]

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

Generated on Tue Jun 12 2012 14:11:48 for XDispatch by Doxygen 1.8.0
© 2010-2012 MLBA (about | privacy) All Rights reserved.