1# type_def.h 2 3<!--Kit: Function Flow Runtime Kit--> 4<!--Subsystem: Resourceschedule--> 5<!--Owner: @chuchihtung; @yanleo--> 6<!--Designer: @geoffrey_guo; @huangyouzhong--> 7<!--Tester: @lotsof; @sunxuhao--> 8<!--Adviser: @foryourself--> 9 10## Overview 11 12The **type_def.h** file declares the common types. 13 14**File to include**: <ffrt/type_def.h> 15 16**Library**: libffrt.z.so 17 18**System capability**: SystemCapability.Resourceschedule.Ffrt.Core 19 20**Since**: 10 21 22**Related module**: [FFRT](capi-ffrt.md) 23 24## Summary 25 26### Variables 27 28| Name | typedef Keyword| Description | 29|-----|------------|------------------------| 30| int | ffrt_timer_t | Handle to the timer. | 31| int | ffrt_qos_t | QoS type. | 32| using qos = int | - | QoS type.<br>**Since**: 10| 33 34### Structs 35 36| Name| typedef Keyword | Description | 37| -- |-------------------------------------------------------|--------------| 38| [ffrt_function_header_t](capi-ffrt-ffrt-function-header-t.md) | ffrt_function_header_t | Describes a task execution function. | 39| [ffrt_dependence_t](capi-ffrt-ffrt-dependence-t.md) | ffrt_dependence_t | Describes dependency data. | 40| [ffrt_deps_t](capi-ffrt-ffrt-deps-t.md) | ffrt_deps_t | Describes dependencies. | 41| [ffrt_task_attr_t](capi-ffrt-ffrt-task-attr-t.md) | ffrt_task_attr_t | Describes a task attribute. | 42| [ffrt_queue_attr_t](capi-ffrt-ffrt-queue-attr-t.md) | ffrt_queue_attr_t | Describes a serial queue attribute. | 43| [ffrt_condattr_t](capi-ffrt-ffrt-condattr-t.md) | ffrt_condattr_t | Describes a condition variable attribute.| 44| [ffrt_mutexattr_t](capi-ffrt-ffrt-mutexattr-t.md) | ffrt_mutexattr_t | Describes a mutex attribute. | 45| [ffrt_rwlockattr_t](capi-ffrt-ffrt-rwlockattr-t.md) | ffrt_rwlockattr_t | Describes a read-write lock attribute.| 46| [ffrt_mutex_t](capi-ffrt-ffrt-mutex-t.md) | ffrt_mutex_t | Describes a mutex. | 47| [ffrt_rwlock_t](capi-ffrt-ffrt-rwlock-t.md) | ffrt_rwlock_t | Describes a read-write lock. | 48| [ffrt_cond_t](capi-ffrt-ffrt-cond-t.md) | ffrt_cond_t | Describes a condition variable. | 49| void* | [ffrt_task_handle_t](capi-ffrt-ffrt-task-handle-t.md) | Defines the handle to a task.| 50 51### Enums 52 53| Name| typedef Keyword| Description| 54| -- | -- | -- | 55| [ffrt_queue_priority_t](#ffrt_queue_priority_t) | ffrt_queue_priority_t | Enumerates the task priority types.| 56| [ffrt_qos_default_t](#ffrt_qos_default_t) | ffrt_qos_default_t | Enumerates the task QoS types.| 57| [ffrt_storage_size_t](#ffrt_storage_size_t) | ffrt_storage_size_t | Enumerates the storage sizes available for different types of structs.| 58| [ffrt_function_kind_t](#ffrt_function_kind_t) | ffrt_function_kind_t | Enumerates the task types.| 59| [ffrt_dependence_type_t](#ffrt_dependence_type_t) | ffrt_dependence_type_t | Enumerates the dependency types.| 60| [ffrt_error_t](#ffrt_error_t) | ffrt_error_t | Enumerates the FFRT error codes.| 61| [ffrt_mutex_type](#ffrt_mutex_type) | ffrt_mutex_type | Enumerates the mutex types. **ffrt_mutex_normal** indicates a normal mutex, **ffrt_mutex_recursive** indicates a recursive mutex, and **ffrt_mutex_default** indicates a default mutex.| 62| [qos_default](#qos_default) | - | Enumerates the task QoS types.| 63 64### Function 65 66| Name| typedef Keyword| Description| 67| -- | -- | -- | 68| [typedef void(\*ffrt_function_t)(void*)](#ffrt_function_t) | ffrt_function_t | Defines the type of the pointer to a task execution function.| 69| [typedef void (\*ffrt_poller_cb)(void* data, uint32_t event)](#ffrt_poller_cb) | ffrt_poller_cb | Defines the poller callback function.| 70| [typedef void (\*ffrt_timer_cb)(void* data)](#ffrt_timer_cb) | ffrt_timer_cb | Defines the timer callback function.| 71 72## Enum Description 73 74### ffrt_queue_priority_t 75 76``` 77enum ffrt_queue_priority_t 78``` 79 80**Description** 81 82Enumerates the task priority types. 83 84**Since**: 12 85 86| Enum Item| Description| 87| -- | -- | 88| ffrt_queue_priority_immediate = 0 | Immediate priority.| 89| ffrt_queue_priority_high | High priority.| 90| ffrt_queue_priority_low | Low priority.| 91| ffrt_queue_priority_idle | Lowest priority.| 92 93### ffrt_qos_default_t 94 95``` 96enum ffrt_qos_default_t 97``` 98 99**Description** 100 101Enumerates the task QoS types. 102 103**Since**: 10 104 105| Enum Item| Description| 106| -- | -- | 107| ffrt_qos_inherit = -1 | Inherited task QoS.| 108| ffrt_qos_background | Background task.| 109| ffrt_qos_utility | Real-time utility.| 110| ffrt_qos_default | Default type.| 111| ffrt_qos_user_initiated | User initiated.| 112 113### ffrt_storage_size_t 114 115``` 116enum ffrt_storage_size_t 117``` 118 119**Description** 120 121Enumerates the storage sizes available for different types of structs. 122 123**Since**: 10 124 125| Enum Item| Description | 126| -- |---------------------| 127| ffrt_task_attr_storage_size = 128 | Storage size for the task attribute struct. | 128| ffrt_auto_managed_function_storage_size = 64 + sizeof(ffrt_function_header_t) | Storage size for the task execution function struct. | 129| ffrt_mutex_storage_size = 64 | Storage size for the mutex struct. | 130| ffrt_cond_storage_size = 64 | Storage size for the condition variable struct. | 131| ffrt_queue_attr_storage_size = 128 | Storage size for the queue attribute struct. | 132| ffrt_rwlock_storage_size = 64 | Read-write lock.<br>**Since**: 18| 133| ffrt_fiber_storage_size| Fiber size across different platforms (in bytes). AArch64 architecture: 22 bytes; Arm architecture: 64 bytes; x86_64 architecture: 8 bytes; other platforms: not supported.<br>**Since**: 20 | 134 135### ffrt_function_kind_t 136 137``` 138enum ffrt_function_kind_t 139``` 140 141**Description** 142 143Task type. 144 145**Since**: 10 146 147| Enum Item| Description| 148| -- | -- | 149| ffrt_function_kind_general | General task.| 150| ffrt_function_kind_queue | Queue task.| 151 152### ffrt_dependence_type_t 153 154``` 155enum ffrt_dependence_type_t 156``` 157 158**Description** 159 160Enumerates the dependency types. 161 162**Since**: 10 163 164| Enum Item| Description| 165| -- | -- | 166| ffrt_dependence_data | Data dependency.| 167| ffrt_dependence_task | Task dependency.| 168 169### ffrt_error_t 170 171``` 172enum ffrt_error_t 173``` 174 175**Description** 176 177Enumerates the FFRT error codes. 178 179**Since**: 10 180 181| Enum Item| Description| 182| -- | -- | 183| ffrt_error = -1 | Failure.| 184| ffrt_success = 0 | Success.| 185| ffrt_error_nomem = ENOMEM | Insufficient memory.| 186| ffrt_error_timedout = ETIMEDOUT | Timeout.| 187| ffrt_error_busy = EBUSY | Try again.| 188| ffrt_error_inval = EINVAL | Invalid value.| 189 190### ffrt_mutex_type 191 192``` 193enum ffrt_mutex_type 194``` 195 196**Description** 197 198Enumerates the mutex types. **ffrt_mutex_normal** indicates a normal mutex, **ffrt_mutex_recursive** indicates a recursive mutex, and **ffrt_mutex_default** indicates a default mutex. 199 200**Since**: 12 201 202| Enum Item| Description| 203| -- | -- | 204| ffrt_mutex_normal = 0 | Normal mutex.| 205| ffrt_mutex_recursive = 2 | Recursive mutex.| 206| ffrt_mutex_default = ffrt_mutex_normal | Default mutex.| 207 208### qos_default 209 210``` 211enum qos_default 212``` 213 214**Description** 215 216Enumerates the task QoS types. 217 218**Since**: 10 219 220| Enum Item| Description| 221| -- | -- | 222| qos_inherit = ffrt_qos_inherit | Inherited task QoS.| 223| qos_background = ffrt_qos_background | Background task.| 224| qos_utility = ffrt_qos_utility | Real-time utility.| 225| qos_default = ffrt_qos_default | Default type.| 226| qos_user_initiated = ffrt_qos_user_initiated | User initiated.| 227 228 229## Function Description 230 231### ffrt_function_t() 232 233``` 234typedef void(*ffrt_function_t)(void*) 235``` 236 237**Description** 238 239Defines the type of the pointer to a task execution function. 240 241**Since**: 10 242 243### ffrt_poller_cb() 244 245``` 246typedef void (*ffrt_poller_cb)(void* data, uint32_t event) 247``` 248 249**Description** 250 251Defines the poller callback function. 252 253**Since**: 12 254 255### ffrt_timer_cb() 256 257``` 258typedef void (*ffrt_timer_cb)(void* data) 259``` 260 261**Description** 262 263Defines the timer callback function. 264 265**Since**: 12 266