类型名 |
定义 |
使用注意 |
|---|---|---|
dispatch_block_t |
typedef void (^dispatch_block_t)(void); |
一个入参为空返回值也为空的Block类型。 注意,如果要把一个^{ }所描述的block赋值给某个dispatch_block_t变量,请确保它的所有使用和^{ }发生在同一个作用域。这是因为^{ }是临时在栈上分配产生的。 例如: dispatch_block_t block;
if (...) {
block = ^{ ... };
} else {
block = ^{ ... };
}
block(); 上面的使用就是非法的。具体原因请参见GCD Reference中dispatch_block_t的章节。 |
dispatch_function_t |
typedef void (*dispatch_function_t)(void *); |
一个入参为void *类型返回值为空的函数指针。 |
dispatch_object_t |
typedef union { struct _os_object_s *_os_obj; struct dispatch_object_s *_do; struct dispatch_queue_s *_dq; struct dispatch_queue_attr_s *_dqa; struct dispatch_group_s *_dg; struct dispatch_source_s *_ds; struct dispatch_mach_s *_dm; struct dispatch_mach_msg_s *_dmsg; struct dispatch_semaphore_s *_dsema; struct dispatch_data_s *_ddata; struct dispatch_io_s *_dchannel; } dispatch_object_t |
各个其它类型的dispatch对象的结构体指针,都是一个dispatch_object_t。dispatch_object_t是一个union。 |
dispatch_once_t |
typedef long dispatch_once_t; |
dispatch_once_t变量用来标识任务是未执行、正在执行、还是已执行完成的状态。如果两个线程在同一个dispatch_once_t上同时调用dispatch_once,那么其中一个线程会执行任务,另一个线程会同步等待任务执行完。如果任务曾经执行完成过,那么dispatch_once立即返回不会再次执行任务。 注意dispatch_once_t变量应该定义在全局或静态作用域。 |
dispatch_queue_t |
typedef struct dispatch_queue_s *dispatch_queue_t; |
dispatch_queue_s内部的结构体成员非常复杂,且不对外暴露,因此不展开描述。 |
dispatch_time_t |
typedef uint64_t dispatch_time_t; |
- |
dispatch_queue_attr_t |
typedef struct dispatch_queue_attr_s *dispatch_queue_attr_t; |
- |
dispatch_queue_main_t |
typedef struct dispatch_queue_static_s *dispatch_queue_main_t |
- |
dispatch_queue_global_t |
typedef struct dispatch_queue_global_s *dispatch_queue_global_t |
- |
dispatch_qos_class_t |
typedef unsigned int dispatch_qos_class_t |
- |
dispatch_group_t |
typedef struct dispatch_group_s *dispatch_group_t; |
- |