Function

dispatch_queue_set_specific

Sets the key/value data for the specified dispatch queue.

Declaration

void dispatch_queue_set_specific(dispatch_queue_t queue, const void *key, void *context, dispatch_function_t destructor);

Parameters

queue

The queue on which to set the specified key/value data. This parameter must not be NULL.

key

The key you want to use to identify the associated context data. Keys are only compared as pointers and are never dereferenced. Thus, you can use a pointer to a static variable for a specific subsystem or any other value that allows you to identify the value uniquely. Specifying a pointer to a string constant is not recommended. NULL is not a valid value for the key and attempts to set context data with a NULL key are ignored.

context

The context data to associate with key. This parameter may be NULL.

destructor

A destructor function that you can use to release your context data. This parameter may be NULL. If context is NULL, your destructor function is ignored.

Discussion

Use this method to associate custom context data with a dispatch queue. Blocks executing on the queue can use the dispatch_get_specific function to retrieve this data while they are running.

See Also

Managing Dispatch Queues

Dispatch Queue Types

Attributes to use when creating new dispatch queues.

dispatch_queue_t

A dispatch queue is a lightweight object to which your application submits blocks for subsequent execution.

dispatch_get_main_queue

Returns the serial dispatch queue associated with the application’s main thread.

dispatch_get_global_queue

Returns a system-defined global concurrent queue with the specified quality of service class.

dispatch_get_current_queue

Returns the queue on which the currently executing block is running.

Deprecated
dispatch_set_target_queue

Sets the target queue for the given object.

dispatch_async

Submits a block for asynchronous execution on a dispatch queue and returns immediately.

dispatch_async_f

Submits an application-defined function for asynchronous execution on a dispatch queue and returns immediately.

dispatch_sync_f

Submits an application-defined function for synchronous execution on a dispatch queue.

dispatch_after

Enqueue a block for execution at the specified time.

dispatch_after_f

Enqueues an application-defined function for execution at a specified time.

dispatch_apply_f

Submits an application-defined function to a dispatch queue for multiple invocations.

dispatch_queue_get_label

Returns the label specified for the queue when the queue was created.

dispatch_get_specific

Returns the value for the key associated with the current dispatch queue.

dispatch_queue_get_specific

Gets the value for the key associated with the specified dispatch queue.

dispatch_once_t

A predicate for use with the dispatch_once function.

dispatch_once

Executes a block object once and only once for the lifetime of an application.

dispatch_once_f

Executes an application-defined function once and only once for the lifetime of an application.

dispatch_main

Executes blocks submitted to the main queue.