In which case, if any, could the `_f` Grand Central Dispatch options in Swift be chosen?

Based on Apple Concurrency Programming Guide and Grand Central Dispatch (GCD). There are two options for GCD calls.

"Block" Flavor. dispatch_block_ta fragrance that can use the standard Swift closure:

void dispatch_async( dispatch_queue_t queue, 
                     dispatch_block_t block );

In cases where a block lock allocates storage on the stack

typedef void (^dispatch_block_t)(void);

"Function" Aroma. An attribute dispatch_function_tthat has a context object and a function pointer.

void dispatch_async_f( dispatch_queue_t queue, 
                       void *context, 
                       dispatch_function_t work );

The context object assigned to applications is passed to the submit function workas a parameter to the object pointer void *.

typedef void (*dispatch_function_t)(void *); 


_f, dispatch_async_f dispatch_sync_f , .

?

- , Grand Central Dispatch _f context + fuction Swift?

+4
2

Objective-C Swift , API- block/clos GCD. , GCD API , _f (.. C).

, , API, , Swift. , _f, , , , ( GCD/Run Loops ).

+3

Source: https://habr.com/ru/post/1613126/


All Articles