Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dispatch_api(3) [debian man page]

dispatch_api(3) 					   BSD Library Functions Manual 					   dispatch_api(3)

NAME
dispatch_api -- Designing API using dispatch DESCRIPTION
The following is a brief summary of some of the common design patterns to consider when designing and implementing API in terms of dispatch queues and blocks. A general recommendation is to allow both a callback block and target dispatch queue to be specified. This gives the application the greatest flexibility in handling asynchronous events. It's also recommended that interfaces take only a single block as the last parameter. This is both for consistency across projects, as well as the visual aesthetics of multiline blocks that are declared inline. The dispatch queue to which the block will be submitted should immedi- ately precede the block argument (second-to-last argument). For example: read_async(file, callback_queue, ^{ printf("received callback. "); }); When function pointer alternatives to interfaces that take blocks are provided, the argument order of the function signature should be iden- tical to the block variant; with the exception that the block argument is replaced with a context pointer, and a new last parameter is added, which is the function to call. The function based callback should pass the context pointer as the first argument, and the subsequent arguments should be identical to the block based variant (albeit offset by one in order). It is also important to use consistent naming. The dispatch API, for example, uses the suffix "_f" for function based variants. SEE ALSO
dispatch(3), dispatch_async(3), dispatch_queue_create(3) Darwin May 1, 2009 Darwin

Check Out this Related Man Page

dispatch_after(3)					   BSD Library Functions Manual 					 dispatch_after(3)

NAME
dispatch_after -- schedule blocks for deferred execution SYNOPSIS
#include <dispatch/dispatch.h> void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, void (^block)(void)); void dispatch_after_f(dispatch_time_t when, dispatch_queue_t queue, void *context, void (*function)(void *)); DESCRIPTION
The dispatch_after() function submits the block to the given queue at the time specified by the when parameter. The when parameter is a value created by dispatch_time() or dispatch_walltime(). For a more detailed description about submitting blocks to queues, see dispatch_async(3). CAVEATS
dispatch_after() retains the passed queue. Specifying DISPATCH_TIME_NOW as the when parameter is supported, but is not as efficient as calling dispatch_async(). The result of passing DISPATCH_TIME_FOREVER as the when parameter is undefined. FUNDAMENTALS
The dispatch_after() function is a wrapper around dispatch_after_f(). SEE ALSO
dispatch(3), dispatch_async(3), dispatch_time(3) Darwin May 1, 2009 Darwin
Man Page