Title: Theory / Important / CS / Programming / Objective-C / Documentation / Queue
Tags: automatedNewLineAfterCommaSpace constant
On every note of this deck, unless a note says otherwise:
Context: Objective-C
Language: Objective-C

Name: A serial queue
Definition: A queue taking tasks and executing them one by one, in order in which they were added in the queue
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html

Instruction: [queue
  addOperation:operation
]
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Effect: Add operation to queue
Variables: NSOperationQueue *queue

Name: Grand Central Dispatch
Definition: A technology for executing asynchronous tasks concurrently.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Abbreviation: GCD

Typ: dispatch_queue_t
Meaning: type of dispatch queue
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Language: Objective-C

Instruction: dispatch_async(
  queue,
  block
);
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Effect: execute block asynchronously on queue
Returns: immediately
Variables: dispatch_queue_t queue
dispatch_block_t block

Instruction: dispatch_sync(
  queue,
  block
);
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: execute foo synchronously
Returns: after execution (and what value)
Variables: dispatch_queue_t queue
dispatch_block_t block

Name: A task
Definition: A quantity of work to be performed.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: A serial dispatch queue
Definition: A dispatch queue that execute one task at a time on a distinct thread
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Name2: private dispatch queues
Intuition: synchronize access to a specific resource.

Name: A concurrent dispatch queue
Definition: execute and manage one or more tasks concurrently on distinct threads
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Name2: global dispatch queue

Name: The main dispatch queue
Definition: a globally available serial queue that executes tasks on the application’s main thread.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Intuition: key synchronization point for an application.

Question: Advantage of dispatch queue over thread
Answer: simplicity of the work-queue programming model/
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Answer2: Serial dispatch queue avoid the need for lock to access a resource
Answer3: Dispatch queue may require less threads, hence require less kernel and user-space memory
Answer4: concurrent dispatch queue deals with the number of task to execute depending on the available number of cores

Question: Constraint on adding a task in a queue
Answer: The task must be ready to execute
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C

Name: A dispatch semaphore
Definition: Similar to a traditional semaphore, but call down to the kernel only if required
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.

Name: A dispatch source
Definition: a fundamental data type that coordinates the processing of specific low-level system events
generates notifications in response to specific types of system events
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Question: What kind of value can a block that should run asynchronously capture
Answer: scalar
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Answer2: object that you take ownership of, or copy
Kind: N

Question: How to know whether it's worth executing a job in a queue or inline
Answer: measure the overhead and the time taken by the job itself
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Kind: N

Question: How to share data between jobs in the same queue
Answer: use the context pointer of the dispatch queue to store the data
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Kind: N

Question: What to do if a block creates many objective-c objects
Answer: enclose parts of your block’s code in an @autorelease block to handle the memory management for those objects
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Kind: N

Typ: dispatch_queue_t
Meaning: a FIFO structure that manages the tasks you submit to it.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Language: Objective-C
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Name: dispatch queue
Kind: N
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_get_global_queue(
  DISPATCH_QUEUE_PRIORITY_(LOW|DEFAULT|HIGH),
  0
);
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: the global concurrent dispatch queue with low|default|high priority
Extra: second argument is reserved for future use
Typ: dispatch_queue_global_t
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_queue_create(
  "name",
  NULL
);
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: a new serial queue, named name
Extra: second argument is reserved for future use
Typ: dispatch_queue_t
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_get_current_queue()
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Returns: the queue on which the currently executing block is running.
Typ: dispatch_queue_t
Intuition: for debugging or identity of the current queue
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_get_main_queue()
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: the serial dispatch queue associated with your application’s main thread
Typ: dispatch_queue_t
Index: What to do if a block creates many objective-c objects

Question: What to do when using queue
Answer: if it's a global dispatch queue, nothing
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Variables: dispatch_get_main_queue()
Answer2: Otherwise call dispatch_retain before using it. Call dispatch_release when you no longer need it.
Index: What to do if a block creates many objective-c objects
Kind: Objective-C

Instruction: dispatch_retain(object)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: increase the reference count by 1
Variables: dispatch_object_t object
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_release
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: decrease the reference count by 1
Variables: dispatch_object_t object
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_(s|g)et_context
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: todo
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_set_finalizer(block)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: call block when the reference counter go down to 0
Variables: dispatch_object_t object
dispatch_function_t finalizer
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_async(
  queue,
  block
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: Add block to queue
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: immediately
Variables: dispatch_queue_t queue;
Index: What to do if a block creates many objective-c objects

Question: When a task is done with a computation, how can it return a result to the caller
Answer: The caller must give its queue and a block allowing to register the result. This block is then added with the computed result on the given queue
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Index: What to do if a block creates many objective-c objects

Question: What is the main risk with synchronous task
Answer: If the task is put on the current queue, it creates a deadlock
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Context: Objective-C
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_apply(
  count,
  queue,
  block
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: add in queue block, called with all arguments from 0 to count - 1
Variables: size_t iterations
dispatch_queue_t queue
void (^block)(size_t iteration)
Intuition: block does enough work to be worth the cost of planning
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_main()
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: start to execute the content of the main queue
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Extra: only useful if the run loop is not used
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_suspend(queue)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: increase the number of time queue is suspended. Ensuring no more task start until the queue is not suspended anymore
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_resume(queue)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: decrease the number of time queue is suspended. If the queue is not suspended anymore, it can restart executing
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_semaphore_create(n)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: a semaphore for n ressources
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_semaphore_wait(dispatch_semaphore)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: acquire one ressource from dispatch_semaphore
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: when the semaphore is available
Variables: dispatch_semaphore_t (?) dispatch_semaphore
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_semaphore_signal(dispatch_semaphore)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Effect: release one ressource from dispatch_semaphore
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Variables: dispatch_semaphore_t (?) dispatch_semaphore
Index: What to do if a block creates many objective-c objects

Typ: dispatch_group_t
Meaning: a way to monitor a set of block objects for completion.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Language: Objective-C
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Name: A dispatch group
Kind: dispatch_semaphore_signal(dispatch_semaphore)
Index: What to do if a block creates many objective-c objects

Instruction: dispatch_group_create()
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: A new dispatch group
Extra: a way to monitor a set of block objects for completion.
Typ: dispatch_group_t
Index: What to do if a block creates many objective-c objects
Kind: dispatch_semaphore_signal(dispatch_semaphore)

Instruction: dispatch_group_async(
  group,
  queue,
  block
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html
Chapter: Constraint on adding a task in a queue
Section: a globally available serial queue that executes tasks on the application’s main thread.
Returns: Same as `dispatch_async(  queue, block)` and add the task to group
Extra: a way to monitor a set of block objects for completion.
Index: What to do if a block creates many objective-c objects

Name: Timer dispatch source
Definition: A dispatch source used to process periodic events. A timer source calls your custom event handler at regular, time-based intervals.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Name: Signal dispatch source
Definition: A dispatch source used to process UNIX signals. A signal source calls your custom event handler whenever the process receives a UNIX signal.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Name: Descriptor dispatch source
Definition: A dispatch source used to process file-related events. A file descriptor source calls your custom event handler either when file data is available for reading or writing or in response to file system changes
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: process dispatch source
Definition: A dispatch source that notify you of process-related events
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Name: match port dispatch source
Definition: A dispatch source that notify you of match-related events
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Name: custom dispatch source
Definition: A dispatch source that you define and trigger yourself
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html

Question: How do dispatch source deal with emitting a new task when previous one was not executed
Answer: They update the previous task to indicate that multiple event occured. Exact update depend on the specific source
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Section: A dispatch source that you define and trigger yourself
Context: Objective-C

Question: How to create a dispatch source
Answer: Create the dispatch source using the dispatch_source_create function.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Section: A dispatch source that you define and trigger yourself
Context: Objective-C
Answer2: Configure the dispatch source:
Assign an event handler to the dispatch source; see Writing and Installing an Event Handler.
For timer sources, set the timer information using the dispatch_source_set_timer function;
Answer3: Optionally assign a cancellation handler to the dispatch source;
Answer4: Call the dispatch_resume function to start processing events;

Instruction: dispatch_source_create(
  type,
  descriptor,
  n,
  queue
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Returns: a suspended dispatch source
Typ: dispatch_source_t

Instruction: dispatch_source_set_event_handler(
  source,
  block
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: when source has an event, add block to its queue
Variables: dispatch_source_t source

Instruction: dispatch_resume(source)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: restart source
Variables: dispatch_source_t source

Instruction: dispatch_source_get_data(source)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Returns: any pending data associated with the event.
Variables: dispatch_source_t source

Instruction: dispatch_source_get_handle(source)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Returns: the underlying system data type that the dispatch source manages.
Variables: dispatch_source_t source

Instruction: dispatch_source_get_mask(source)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Returns: The event flags that were used to create the dispatch source.
Variables: dispatch_source_t source

Instruction: dispatch_source_set_cancel_handler(
  source,
  block
);
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: When source is cancelled, execute block
Variables: dispatch_source_t source
Intuition: Release resources you captured. Log end.

Instruction: dispatch_set_target_queue(
  source,
  queue
);
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: Move source to queue
Variables: dispatch_source_t source

Typ: dispatch_time_t
Meaning: An abstract representation of time.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Language: Objective-C
Implementation: uint64_t

Instruction: dispatch_source_set_timer(
  source,
  start,
  interval,
  leeway
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: Set the source to start at timer, using timer start, with message sent at interval, ideally with at most leeway delay

Instruction: dispatch_after(
  when,
  queue,
  block
)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: exexcute block at when on queue

Question: Advantage of synchronous signal handler over asynchronous one
Answer: synchronous signal handler can catch and cancel a signal, avoiding the app to clause
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Context: Objective-C
Answer2: synchronous signal handler can monitor SIGILL, SIGBUS and SIGSEV
Answer3: Synchronous signal handler can answer immediately

Question: Advantage of asynchronous signal handler over synchronous one
Answer: asynchronous signal handler can use any functions, even one forbidden in synchronous handling
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Context: Objective-C
Answer2: asynchronous signal handler have less concurrency issue if they are on a sequential queue
Answer3: Multiple signals can be handled simultaneously
Answer4: Monitoring can be done independently of any signal application linked to it

Instruction: dispatch_source_cancel(source)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html
Effect: stops the delivery of new events
Variables: dispatch_source_t source

Question: Advantage of grand central dispatch over threads
Answer: It reduces the memory penalty your application pays for storing thread stacks in the application’s memory space.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html
Context: Objective-C
Answer2: It eliminates the code needed to create and configure your threads.
Answer3: It eliminates the code needed to manage and schedule work on threads.

Name: Worker thread
Definition: A thread with a specific task in mind. Dispatch task to this thread periodically
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html

Name: Thread pools
Definition: Have a set of generic threads. When there are task to execute, send them to the thread. If no thread is available, enqueue it
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html

Question: When is thread better than grand central dispatch
Answer: If you need low latency, thread allows for finer control
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html
Context: Objective-C
Answer2: thread may allow to call some low-level posix command that are not safe in tasks
Name: Thread pools

Function: void join()
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html
Name: A joinable thread
Etymology: A thread whose resources are not reclaimed immediately upon termination. Joinable threads must be explicitly detached or be joined by another thread before the resources can be reclaimed. Joinable threads provide a return value to the thread that joins with them.
Language: Objective-C

Name: A custom source
Definition: A dispatch source used to process application-defined events. A custom source calls your custom event handler in response to events that your application generates.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: A dispatch queue
Definition: A Grand Central Dispatch (GCD) structure that you use to execute your application’s tasks.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: A global dispatch queue
Definition: A dispatch queue provided to your application automatically by Grand Central Dispatch (GCD).
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: Mach port dispatch source
Definition: A dispatch source used to process events arriving on a Mach port.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Meaning: manage the execution of operation objects.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html
Language: Objective-C
Subtype of: NSOperationQueue
Name: Operation object

Name: Private dispatch source
Definition: A dispatch source used to handle process-related events. A process source calls your custom event handler in response to changes to the process you specify.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Name: Run loop
Definition: An event-processing loop, during which events are received and dispatched to appropriate handlers.
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html

Instruction: foo_f
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html
Effect: same as foo, but take a function instead of a block

Constant: DISPATCH_QUEUE_PRIORITY_HIGH
Meaning: Tasks run at the highest priority, which is equivalent to the user-initiated quality-of-service level.
Page: https://developer.apple.com/documentation/dispatch/dispatch_queue_priority_high?language=objc
Language: Objective-C

Constant: DISPATCH_QUEUE_PRIORITY_DEFAULT
Meaning: Tasks run at the default priority, which is equivalent to the default quality-of-service.
Page: https://developer.apple.com/documentation/dispatch/dispatch_queue_priority_default?language=objc
Language: Objective-C

Constant: DISPATCH_QUEUE_PRIORITY_LOW
Meaning: Tasks run at a low priority, which is equivalent to the utility quality-of-service level.
Page: https://developer.apple.com/documentation/dispatch/dispatch_queue_priority_default?language=objc
Language: Objective-C

Constant: DISPATCH_QUEUE_PRIORITY_BACKGROUND
Meaning: Tasks run at the background priority, which is equivalent to the background quality-of-service level.
Page: https://developer.apple.com/documentation/dispatch/dispatch_queue_priority_background?language=objc
Language: Objective-C

Instruction: dispatch_set_context(
  object,
  context
)
Page: https://developer.apple.com/documentation/dispatch/1452807-dispatch_set_context
Effect: Set the new context of object to context
Variables: dispatch object_t object
void *context

Instruction: dispatch_get_context(object)
Page: https://developer.apple.com/documentation/dispatch/1453005-dispatch_get_context
Returns: the application-defined context of an object.
Variables: dispatch object_t object
Typ: void*

Typ: CFRunLoopRef
Meaning: A reference to a run loop object.
Page: https://developer.apple.com/documentation/dispatch/1453005-dispatch_get_context
Language: Objective-C

Instruction: dipatch_time(
  when,
  delta
)
Page: https://developer.apple.com/documentation/dispatch/1420519-dispatch_time
Returns: The dipastch_time_t when + delta
Typ: NSZone

Instruction: dipatch_walltime(
  when,
  delta
)
Page: https://developer.apple.com/documentation/dispatch/1420517-dispatch_walltime
Returns: The dipastch_time_t when + delta
Typ: NSZone

Instruction: dipatch_walltime(
  null,
  delta
)
Page: https://developer.apple.com/documentation/dispatch/1420517-dispatch_walltime
Returns: The dipastch_time_t gettimeofday + delta
Typ: NSZone

Constant: DISPATCH_SOURCE_TYPE_READ
Meaning: A type of dispatch source for monitoring read operations on a file descriptor.
Page: https://developer.apple.com/documentation/dispatch/1420517-dispatch_walltime
Language: Objective-C
Typ: NSZone

Constant: DISPATCH_SOURCE_TYPE_WRITE
Meaning: A type of dispatch source for monitoring write operations on a file descriptor.
Page: https://developer.apple.com/documentation/dispatch/1420517-dispatch_walltime
Language: Objective-C
Typ: NSZone

Constant: DISPATCH_SOURCE_TYPE_VNODE
Meaning: A type of dispatch source for monitoring changes to a file system object.
Page: https://developer.apple.com/documentation/dispatch/dispatch_source_type_vnode
Language: Objective-C
Typ: NSZone