*/\r
static void _destroyTaskPool( _taskPool_t * const pTaskPool );\r
\r
-/**\r
- * Set the exit condition.\r
- *\r
- * @param[in] pTaskPool The task pool to destroy.\r
- * @param[in] threads The number of threads active in the task pool at shutdown time.\r
- *\r
- */\r
-static void _signalShutdown( _taskPool_t * const pTaskPool,\r
- uint32_t threads );\r
-\r
/**\r
* Places a job in the dispatch queue.\r
*\r
if( TASKPOOL_FAILED( status ) )\r
{\r
/* Set the exit condition for the newly created threads. */\r
- _signalShutdown( pTaskPool, threadsCreated );\r
+#pragma message( "Threads need to be created statically here to ensure creation cannot fail as there is no shutdown mechanism." )\r
_destroyTaskPool( pTaskPool );\r
}\r
\r
{\r
xTimerDelete( pTaskPool->timer, 0 );\r
}\r
-\r
- if( pTaskPool->dispatchSignal != NULL )\r
- {\r
- vSemaphoreDelete( pTaskPool->dispatchSignal );\r
- }\r
}\r
\r
/* ---------------------------------------------------------------------------------------------- */\r
IotTaskPool_Assert( pUserContext != NULL );\r
\r
IotTaskPoolRoutine_t userCallback = NULL;\r
- bool running = true;\r
\r
/* Extract pTaskPool pointer from context. */\r
_taskPool_t * pTaskPool = ( _taskPool_t * ) pUserContext;\r
\r
- /* OUTER LOOP: it controls the lifetiem of the worker thread: exit condition for a worker thread\r
- * is setting maxThreads to zero. A worker thread is running until the maximum number of allowed\r
- * threads is not zero and the active threads are less than the maximum number of allowed threads.\r
- */\r
- do\r
+ /* OUTER LOOP: it controls the lifetime of the worker thread. */\r
+ for( ;; )\r
{\r
IotLink_t * pFirst = NULL;\r
_taskPoolJob_t * pJob = NULL;\r
\r
/* Wait on incoming notifications... */\r
+ configASSERT( pTaskPool->dispatchSignal );\r
xSemaphoreTake( pTaskPool->dispatchSignal, portMAX_DELAY );\r
\r
- /* Acquire the lock to check the exit condition, and release the lock if the exit condition is verified,\r
- * or before waiting for incoming notifications.\r
- */\r
+ /* Acquire the lock to check for incoming notifications. */\r
taskENTER_CRITICAL();\r
{\r
/* Dequeue the first job in FIFO order. */\r
/* This job is finished, clear its pointer. */\r
pJob = NULL;\r
userCallback = NULL;\r
-\r
- /* If this thread exceeded the quota, then let it terminate. */\r
- if( running == false )\r
- {\r
- /* Abandon the INNER LOOP. Execution will tranfer back to the OUTER LOOP condition. */\r
- break;\r
- }\r
}\r
\r
/* Acquire the lock before updating the job status. */\r
{\r
taskEXIT_CRITICAL();\r
\r
- /* Abandon the INNER LOOP. Execution will tranfer back to the OUTER LOOP condition. */\r
+ /* Abandon the INNER LOOP. Execution will transfer back to the OUTER LOOP condition. */\r
break;\r
}\r
else\r
}\r
taskEXIT_CRITICAL();\r
}\r
- } while( running == true );\r
-\r
- vTaskDelete( NULL );\r
+ }\r
}\r
\r
/* ---------------------------------------------------------------------------------------------- */\r
}\r
else\r
{\r
- /* Log alocation failure for troubleshooting purposes. */\r
+ /* Log allocation failure for troubleshooting purposes. */\r
IotLogInfo( "Failed to allocate job." );\r
}\r
}\r
\r
/* ---------------------------------------------------------------------------------------------- */\r
\r
-static bool _IsShutdownStarted( const _taskPool_t * const pTaskPool )\r
-{\r
- return( pTaskPool->running == false );\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-static void _signalShutdown( _taskPool_t * const pTaskPool,\r
- uint32_t threads )\r
-{\r
- uint32_t count;\r
-\r
- /* Set the exit condition. */\r
- pTaskPool->running = false;\r
-\r
- /* Broadcast to all active threads to wake-up. Active threads do check the exit condition right after wakein up. */\r
- for( count = 0; count < threads; ++count )\r
- {\r
- ( void ) xSemaphoreGive( pTaskPool->dispatchSignal );\r
- }\r
-}\r
-\r
-/* ---------------------------------------------------------------------------------------------- */\r
-\r
static IotTaskPoolError_t _scheduleInternal( _taskPool_t * const pTaskPool,\r
_taskPoolJob_t * const pJob )\r
{\r
break;\r
\r
case IOT_TASKPOOL_STATUS_COMPLETED:\r
- /* Log mesggesong purposes. */\r
+ /* Log message for debug purposes. */\r
IotLogWarn( "Attempt to cancel a job that is already executing, or canceled." );\r
break;\r
\r
default:\r
- /* Log mesggesong purposes. */\r
+ /* Log message for debug purposes purposes. */\r
IotLogError( "Attempt to cancel a job with an undefined state." );\r
break;\r
}\r
* If this mutex cannot be locked it means that another thread is manipulating the\r
* timeouts list, and will reset the timer to fire again, although it will be late.\r
*/\r
- taskENTER_CRITICAL();\r
+ taskENTER_CRITICAL(); //_RB_ Critical section is too long.\r
{\r
/* Dispatch all deferred job whose timer expired, then reset the timer for the next\r
* job down the line. */\r