Task Pool API Reference
Task pool library
iot_taskpool_types.h
Go to the documentation of this file.
1 /*
2  * IoT Common V1.0.0
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
28 #ifndef IOT_TASKPOOL_TYPES_H_
29 #define IOT_TASKPOOL_TYPES_H_
30 
31 /* The config header is always included first. */
32 #include "iot_config.h"
33 
34 /* Standard includes. */
35 #include <stdbool.h>
36 #include <stdint.h>
37 
38 /* Platform types includes. */
40 
41 /* Linear containers (lists and queues) include. */
42 #include "iot_linear_containers.h"
43 
44 /*-------------------------- Task pool enumerated types --------------------------*/
45 
50 typedef enum IotTaskPoolError
51 {
71 
91 
106 
120 
136 
146 
156 typedef enum IotTaskPoolJobStatus
157 {
163 
169 
175 
181 
187 
194 
195 /*------------------------- Task pool types and handles --------------------------*/
196 
213 typedef struct _taskPool * IotTaskPool_t;
214 
223 typedef struct IotTaskPoolJobStorage
224 {
226  void * dummy2;
227  void * dummy3;
228  uint32_t dummy4;
231 
246 typedef struct _taskPoolJob * IotTaskPoolJob_t;
247 
248 /*------------------------- Task pool parameter structs --------------------------*/
249 
259 typedef void ( * IotTaskPoolRoutine_t )( IotTaskPool_t pTaskPool,
260  IotTaskPoolJob_t pJob,
261  void * pUserContext );
262 
273 typedef struct IotTaskPoolInfo
274 {
284  uint32_t minThreads;
285  uint32_t maxThreads;
286  uint32_t stackSize;
287  int32_t priority;
289 
290 /*------------------------- TASKPOOL defined constants --------------------------*/
291 
323 /* @[define_taskpool_initializers] */
325 #define IOT_TASKPOOL_INFO_INITIALIZER_SMALL { .minThreads = 1, .maxThreads = 1, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
326 
327 #define IOT_TASKPOOL_INFO_INITIALIZER_MEDIUM { .minThreads = 1, .maxThreads = 2, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
328 
329 #define IOT_TASKPOOL_INFO_INITIALIZER_LARGE { .minThreads = 2, .maxThreads = 3, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
330 
331 #define IOT_TASKPOOL_INFO_INITIALIZER_XLARGE { .minThreads = 2, .maxThreads = 4, .stackSize = IOT_THREAD_DEFAULT_STACK_SIZE, .priority = IOT_THREAD_DEFAULT_PRIORITY }
332 
333 #define IOT_TASKPOOL_INFO_INITIALIZER IOT_TASKPOOL_INFO_INITIALIZER_MEDIUM
334 
335 #define IOT_TASKPOOL_INITIALIZER NULL
336 
337 #define IOT_TASKPOOL_JOB_STORAGE_INITIALIZER { { NULL, NULL }, NULL, NULL, 0, IOT_TASKPOOL_STATUS_UNDEFINED }
338 
339 #define IOT_TASKPOOL_JOB_INITIALIZER NULL
340 /* @[define_taskpool_initializers] */
341 
349 #define IOT_TASKPOOL_JOB_HIGH_PRIORITY ( ( uint32_t ) 0x00000001 )
350 
357 #define IOT_SYSTEM_TASKPOOL ( NULL )
358 
359 #endif /* ifndef IOT_TASKPOOL_TYPES_H_ */
IOT_TASKPOOL_SHUTDOWN_IN_PROGRESS
Task pool operation failed because of an invalid parameter.
Definition: iot_taskpool_types.h:135
IotTaskPoolRoutine_t
void(* IotTaskPoolRoutine_t)(IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pUserContext)
Callback type for a user callback.
Definition: iot_taskpool_types.h:259
IotTaskPoolInfo_t::priority
int32_t priority
priority for every task pool thread. The priority for each thread is fixed after the task pool is cre...
Definition: iot_taskpool_types.h:287
IOT_TASKPOOL_STATUS_CANCELED
Job has been canceled before executing.
Definition: iot_taskpool_types.h:186
IOT_TASKPOOL_BAD_PARAMETER
Task pool operation failed because at least one parameter is invalid.
Definition: iot_taskpool_types.h:90
IotTaskPoolJobStorage_t::link
IotLink_t link
Placeholder.
Definition: iot_taskpool_types.h:225
IotTaskPoolJobStorage_t::dummy4
uint32_t dummy4
Placeholder.
Definition: iot_taskpool_types.h:228
iot_platform_types.h
IotTaskPool_t
struct _taskPool * IotTaskPool_t
Opaque handle of a Task Pool instance.
Definition: iot_taskpool_types.h:213
IotTaskPoolJobStorage_t::dummy3
void * dummy3
Placeholder.
Definition: iot_taskpool_types.h:227
IotTaskPoolJobStatus_t
IotTaskPoolJobStatus_t
Status codes of task pool Job.
Definition: iot_taskpool_types.h:156
IOT_TASKPOOL_ILLEGAL_OPERATION
Task pool operation failed because it is illegal.
Definition: iot_taskpool_types.h:105
IOT_TASKPOOL_STATUS_SCHEDULED
Job has been queued for execution.
Definition: iot_taskpool_types.h:168
IotTaskPoolInfo_t
Initialization information to create one task pool instance.
Definition: iot_taskpool_types.h:273
IOT_TASKPOOL_STATUS_COMPLETED
Job is executing.
Definition: iot_taskpool_types.h:180
IOT_TASKPOOL_SUCCESS
Task pool operation completed successfully.
Definition: iot_taskpool_types.h:70
IOT_TASKPOOL_NO_MEMORY
Task pool operation failed because allocating memory failed.
Definition: iot_taskpool_types.h:119
IOT_TASKPOOL_CANCEL_FAILED
Task pool cancellation failed.
Definition: iot_taskpool_types.h:144
IotTaskPoolInfo_t::minThreads
uint32_t minThreads
Specifies the operating parameters for a task pool.
Definition: iot_taskpool_types.h:284
IOT_TASKPOOL_STATUS_READY
Job is ready to be scheduled.
Definition: iot_taskpool_types.h:162
IotTaskPoolJobStorage_t
The job storage data structure provides the storage for a statically allocated Task Pool Job instance...
Definition: iot_taskpool_types.h:223
IOT_TASKPOOL_STATUS_DEFERRED
Job has been scheduled for deferred execution.
Definition: iot_taskpool_types.h:174
IotTaskPoolInfo_t::stackSize
uint32_t stackSize
Stack size for every task pool thread. The stack size for each thread is fixed after the task pool is...
Definition: iot_taskpool_types.h:286
IotTaskPoolInfo_t::maxThreads
uint32_t maxThreads
Maximum number of threads in a task pool. A task pool may try and grow the number of active threads u...
Definition: iot_taskpool_types.h:285
IotTaskPoolError_t
IotTaskPoolError_t
Return codes of task pool functions.
Definition: iot_taskpool_types.h:50
IotTaskPoolJobStorage_t::status
IotTaskPoolJobStatus_t status
Placeholder.
Definition: iot_taskpool_types.h:229
iot_linear_containers.h
IotTaskPoolJobStorage_t::dummy2
void * dummy2
Placeholder.
Definition: iot_taskpool_types.h:226
IotTaskPoolJob_t
struct _taskPoolJob * IotTaskPoolJob_t
Opaque handle of a Task Pool Job.
Definition: iot_taskpool_types.h:246
IOT_TASKPOOL_STATUS_UNDEFINED
Job status is undefined.
Definition: iot_taskpool_types.h:192