Search code examples
cgrand-central-dispatch

Context for dispatch source handler


In Grand Central Dispatch, dispatch_source_set_event_handler_f has the signature

void
dispatch_source_set_event_handler_f(dispatch_source_t source, void (*function)(void *));

dispatch_source_set_cancel_handler_f has a similar signature.

What provides the argument for function? The man page doesn't appear to list a function that sets the context.


Solution

  • A dispatch source is a kind of dispatch object, so you can set the context using dispatch_set_context.