Task Pool API Reference
Task pool library
IotTaskPool_Schedule

This function schedules a job created with IotTaskPool_CreateJob against the task pool pointed to by taskPool.

Parameters
[in]taskPoolA handle to an initialized taskpool.
[in]jobA job to schedule for execution. This must be first initialized with a call to IotTaskPool_CreateJob.
[in]flagsFlags to be passed by the user, e.g. to identify the job as high priority by specifying IOT_TASKPOOL_JOB_HIGH_PRIORITY.
Returns
One of the following:
Note
This function will not allocate memory, so it is guaranteed to succeed if the parameters are correct and the task pool was correctly initialized, and not yet destroyed.

Example

// An example of a user context to pass to a callback through a task pool thread.
typedef struct JobUserContext
{
uint32_t counter;
} JobUserContext_t;
// An example of a user callback to invoke through a task pool thread.
static void ExecutionCb( IotTaskPool_t taskPool, IotTaskPoolJob_t job, void * context )
{
( void )taskPool;
( void )job;
JobUserContext_t * pUserContext = ( JobUserContext_t * )context;
pUserContext->counter++;
}
void TaskPoolExample( )
{
JobUserContext_t userContext = { 0 };
IotTaskPool_t taskPool;
// Configure the task pool to hold one thread.
// Provide proper stack size and priority per the application needs.
const IotTaskPoolInfo_t tpInfo = { .minThreads = 1, .maxThreads = 1, .stackSize = 512, .priority = 0 };
// Create a task pool.
IotTaskPool_Create( &tpInfo, &taskPool );
// Statically allocate one job, schedule it.
IotTaskPool_CreateJob( &ExecutionCb, &userContext, &job );
IotTaskPoolError_t errorSchedule = IotTaskPool_Schedule( taskPool, &job, 0 );
switch ( errorSchedule )
{
break;
case IOT_TASKPOOL_BAD_PARAMETER: // Invalid parameters, such as a NULL handle, can trigger this error.
case IOT_TASKPOOL_ILLEGAL_OPERATION: // Scheduling a job that was previously scheduled or destroyed could trigger this error.
case IOT_TASKPOOL_NO_MEMORY: // Scheduling a with flag #IOT_TASKPOOL_JOB_HIGH_PRIORITY could trigger this error.
case IOT_TASKPOOL_SHUTDOWN_IN_PROGRESS: // Scheduling a job after trying to destroy the task pool could trigger this error.
// ASSERT
break;
default:
// ASSERT
}
//
// ... Perform other operations ...
//
IotTaskPool_Destroy( taskPool );
}
IOT_TASKPOOL_SHUTDOWN_IN_PROGRESS
Task pool operation failed because of an invalid parameter.
Definition: iot_taskpool_types.h:75
IOT_TASKPOOL_BAD_PARAMETER
Task pool operation failed because at least one parameter is invalid.
Definition: iot_taskpool_types.h:60
IotTaskPool_t
struct _taskPool * IotTaskPool_t
Opaque handle of a Task Pool instance.
Definition: iot_taskpool_types.h:147
IOT_TASKPOOL_ILLEGAL_OPERATION
Task pool operation failed because it is illegal.
Definition: iot_taskpool_types.h:65
IotTaskPoolInfo_t
Initialization information to create one task pool instance.
Definition: iot_taskpool_types.h:223
IOT_TASKPOOL_SUCCESS
Task pool operation completed successfully.
Definition: iot_taskpool_types.h:55
IOT_TASKPOOL_NO_MEMORY
Task pool operation failed because allocating memory failed.
Definition: iot_taskpool_types.h:70
IotTaskPool_CreateJob
IotTaskPoolError_t IotTaskPool_CreateJob(IotTaskPoolRoutine_t userCallback, void *pUserContext, IotTaskPoolJobStorage_t *const pJobStorage, IotTaskPoolJob_t *const pJob)
Creates a job for the task pool around a user-provided storage.
Definition: iot_taskpool.c:259
IotTaskPoolInfo_t::minThreads
uint32_t minThreads
Specifies the operating parameters for a task pool.
Definition: iot_taskpool_types.h:231
IotTaskPoolError_t
IotTaskPoolError_t
Return codes of task pool functions.
Definition: iot_taskpool_types.h:50
IotTaskPool_Schedule
IotTaskPoolError_t IotTaskPool_Schedule(IotTaskPool_t taskPool, IotTaskPoolJob_t job, uint32_t flags)
This function schedules a job created with IotTaskPool_CreateJob against the task pool pointed to by ...
Definition: iot_taskpool.c:279
IotTaskPoolJob_t
struct _taskPoolJob * IotTaskPoolJob_t
Opaque handle of a Task Pool Job.
Definition: iot_taskpool_types.h:198