Creates a new dispatch source to monitor low-level system events.


dispatch_source_t dispatch_source_create(dispatch_source_type_t type, uintptr_t handle, unsigned long mask, dispatch_queue_t queue);



The type of the dispatch source. For example, to create a timer source, specify DISPATCH_SOURCE_TYPE_TIMER. For a complete list of constants, see dispatch_source_type_t.


The underlying system handle to monitor. The interpretation of this argument is determined by the constant provided in the type parameter.


A mask of flags specifying which events are desired. The interpretation of this argument is determined by the constant provided in the type parameter.


The dispatch queue to which the event handler block is submitted.

Return Value

A new dispatch source object or NULL if the dispatch source could not be created.


Dispatch sources are not reentrant. Any events received while the dispatch source is suspended or while the event handler block is currently executing are coalesced and delivered after the dispatch source is resumed or the event handler block has returned.

Dispatch sources are created in a suspended state. After creating the source and setting any desired attributes (for example, the handler or the context), your application must call dispatch_activate to begin event delivery.

See Also

Creating a Dispatch Source


An object that coordinates the processing of specific low-level system events, such as file-system events, timers, and UNIX signals.


An identifier for the type of system object being monitored by a dispatch source.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software