Task Pool API Reference
Task pool library
|
Go to the documentation of this file.
32 #ifndef IOT_TASKPOOL_INTERNAL_H_
33 #define IOT_TASKPOOL_INTERNAL_H_
36 #include "iot_config.h"
39 #include "private/iot_error.h"
52 #define TASKPOOL_SUCCEEDED( x ) ( ( x ) == IOT_TASKPOOL_SUCCESS )
57 #define TASKPOOL_FAILED( x ) ( ( x ) != IOT_TASKPOOL_SUCCESS )
62 #define TASKPOOL_GOTO_CLEANUP() IOT_GOTO_CLEANUP()
67 #define TASKPOOL_FUNCTION_ENTRY( result ) IOT_FUNCTION_ENTRY( IotTaskPoolError_t, result )
72 #define TASKPOOL_ON_ERROR_GOTO_CLEANUP( expr ) \
73 { if( TASKPOOL_FAILED( status = ( expr ) ) ) { IOT_GOTO_CLEANUP(); } \
79 #define TASKPOOL_ON_NULL_ARG_GOTO_CLEANUP( ptr ) IOT_VALIDATE_PARAMETER( IOT_TASKPOOL, ( ptr != NULL ) )
84 #define TASKPOOL_ON_ARG_ERROR_GOTO_CLEANUP( expr ) IOT_VALIDATE_PARAMETER( IOT_TASKPOOL, ( ( expr ) == false ) )
89 #define TASKPOOL_SET_AND_GOTO_CLEANUP( expr ) IOT_SET_AND_GOTO_CLEANUP( expr )
94 #define TASKPOOL_FUNCTION_CLEANUP() IOT_FUNCTION_CLEANUP_BEGIN()
99 #define TASKPOOL_FUNCTION_CLEANUP_END() IOT_FUNCTION_CLEANUP_END()
104 #define TASKPOOL_NO_FUNCTION_CLEANUP() IOT_FUNCTION_EXIT_NO_CLEANUP()
109 #define TASKPOOL_NO_FUNCTION_CLEANUP_NOLABEL() return status
120 #if IOT_TASKPOOL_ENABLE_ASSERTS == 1
121 #ifndef IotTaskPool_Assert
122 #ifdef Iot_DefaultAssert
123 #define IotTaskPool_Assert( expression ) Iot_DefaultAssert( expression )
125 #error "Asserts are enabled for Task Pool, but IotTaskPool_Assert is not defined"
129 #define IotTaskPool_Assert( expression )
133 #ifdef IOT_LOG_LEVEL_TASKPOOL
134 #define LIBRARY_LOG_LEVEL IOT_LOG_LEVEL_TASKPOOL
136 #ifdef IOT_LOG_LEVEL_GLOBAL
137 #define LIBRARY_LOG_LEVEL IOT_LOG_LEVEL_GLOBAL
139 #define LIBRARY_LOG_LEVEL IOT_LOG_NONE
143 #define LIBRARY_LOG_NAME ( "TASKPOOL" )
150 #if IOT_STATIC_MEMORY_ONLY == 1
179 #ifndef IotTaskPool_MallocJob
180 #ifdef Iot_DefaultMalloc
181 #define IotTaskPool_MallocJob Iot_DefaultMalloc
183 #error "No malloc function defined for IotTaskPool_MallocJob"
187 #ifndef IotTaskPool_FreeJob
188 #ifdef Iot_DefaultFree
189 #define IotTaskPool_FreeJob Iot_DefaultFree
191 #error "No free function defined for IotTaskPool_FreeJob"
195 #ifndef IotTaskPool_MallocTimerEvent
196 #ifdef Iot_DefaultMalloc
197 #define IotTaskPool_MallocTimerEvent Iot_DefaultMalloc
199 #error "No malloc function defined for IotTaskPool_MallocTimerEvent"
203 #ifndef IotTaskPool_FreeTimerEvent
204 #ifdef Iot_DefaultFree
205 #define IotTaskPool_FreeTimerEvent Iot_DefaultFree
207 #error "No free function defined for IotTaskPool_FreeTimerEvent"
220 #define IOT_TASK_POOL_INTERNAL_STATIC ( ( uint32_t ) 0x00000001 )
230 typedef struct _taskPoolCache
245 typedef struct _taskPool
267 typedef struct _taskPoolJob
282 typedef struct _taskPoolTimerEvent
void(* IotTaskPoolRoutine_t)(IotTaskPool_t pTaskPool, IotTaskPoolJob_t pJob, void *pUserContext)
Callback type for a user callback.
Definition: iot_taskpool_types.h:259
The job data structure keeps track of the user callback and context, as well as the status of the job...
Definition: iot_taskpool_internal.h:267
void IotTaskPool_FreeJob(void *ptr)
Free an IotTaskPoolJob_t. This function should have the same same signature as [malloc]....
uint32_t freeCount
A counter to track the number of jobs in the cache.
Definition: iot_taskpool_internal.h:234
SemaphoreHandle_t dispatchSignal
The synchronization object on which threads are waiting for incoming jobs.
Definition: iot_taskpool_internal.h:252
void * IotTaskPool_MallocTimerEvent(size_t size)
Allocate an _taskPoolTimerEvent_t. This function should have the same signature as [malloc].
StaticTimer_t timerBuffer
The timer buffer.
Definition: iot_taskpool_internal.h:256
Represents an operation that is subject to a timer.
Definition: iot_taskpool_internal.h:282
IotListDouble_t freeList
A list ot hold cached jobs.
Definition: iot_taskpool_internal.h:232
void * pUserContext
The user provided context.
Definition: iot_taskpool_internal.h:271
IotTaskPoolJobStatus_t status
The status for the job.
Definition: iot_taskpool_internal.h:273
IotTaskPoolJobStatus_t
Status codes of task pool Job.
Definition: iot_taskpool_types.h:156
The task pool data structure keeps track of the internal state and the signals for the dispatcher thr...
Definition: iot_taskpool_internal.h:245
IotDeQueue_t dispatchQueue
The queue for the jobs waiting to be executed.
Definition: iot_taskpool_internal.h:247
uint32_t flags
Internal flags.
Definition: iot_taskpool_internal.h:272
void * IotTaskPool_MallocJob(size_t size)
Allocate an IotTaskPoolJob_t. This function should have the same signature as [malloc].
TimerHandle_t timer
The timer for deferred jobs.
Definition: iot_taskpool_internal.h:255
bool running
A flag to track whether the task pool is operational or should shut down.
Definition: iot_taskpool_internal.h:257
uint32_t activeThreads
The number of threads in the task pool at any given time.
Definition: iot_taskpool_internal.h:250
IotTaskPoolRoutine_t userCallback
The user provided callback.
Definition: iot_taskpool_internal.h:270
TickType_t expirationTime
When this event should be processed.
Definition: iot_taskpool_internal.h:285
User-facing functions of the task pool library.
StaticSemaphore_t dispatchSignalBuffer
The semaphore buffer.
Definition: iot_taskpool_internal.h:253
_taskPoolCache_t jobsCache
A cache to re-use jobs in order to limit memory allocations.
Definition: iot_taskpool_internal.h:249
IotListDouble_t timerEventsList
The timeouts queue for all deferred jobs waiting to be executed.
Definition: iot_taskpool_internal.h:248
void IotTaskPool_FreeTimerEvent(void *ptr)
Free an _taskPoolTimerEvent_t. This function should have the same signature as[ free ].
StaticSemaphore_t startStopSignalBuffer
The semaphore buffer.
Definition: iot_taskpool_internal.h:254
Task pool jobs cache.
Definition: iot_taskpool_internal.h:230
IotTaskPoolJob_t job
The task pool job associated with this event.
Definition: iot_taskpool_internal.h:286
struct _taskPoolJob * IotTaskPoolJob_t
Opaque handle of a Task Pool Job.
Definition: iot_taskpool_types.h:246
IotLink_t link
The link to insert the job in the dispatch queue.
Definition: iot_taskpool_internal.h:269
int32_t priority
The priority for all task pool threads.
Definition: iot_taskpool_internal.h:251
IotLink_t link
List link member.
Definition: iot_taskpool_internal.h:284