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(3)						   BSD Library Functions Manual 					       dispatch(3)

NAME
dispatch -- the dispatch framework SYNOPSIS
#include <dispatch/dispatch.h> DESCRIPTION
The dispatch framework allows blocks to be scheduled for asynchronous and concurrent execution via the core functions described in dispatch_async(3) and dispatch_apply(3). Dispatch queues are the basic units of organization of blocks. Several queues are created by default, and applications may create additional queues for their own use. See dispatch_queue_create(3) for more information. Dispatch groups allow applications to track the progress of blocks submitted to queues and take action when the blocks complete. See dispatch_group_create(3) for more information. The dispatch framework also provides functions to monitor underlying system events and automatically submit event handler blocks to dispatch queues. SEE ALSO
dispatch_after(3), dispatch_api(3), dispatch_apply(3), dispatch_async(3), dispatch_benchmark(3), dispatch_group_create(3), dispatch_object(3), dispatch_once(3), dispatch_queue_create(3), dispatch_semaphore_create(3), dispatch_source_create(3), dispatch_time(3) Darwin May 1, 2009 Darwin
Man Page