| 1320 | /*-----------------------------------------------------------*/ |
| 1321 | |
| 1322 | BaseType_t xQueueReceive( QueueHandle_t xQueue, |
| 1323 | void * const pvBuffer, |
| 1324 | TickType_t xTicksToWait ) |
| 1325 | { |
| 1326 | BaseType_t xEntryTimeSet = pdFALSE; |
| 1327 | TimeOut_t xTimeOut; |
| 1328 | Queue_t * const pxQueue = xQueue; |
| 1329 | |
| 1330 | /* Check the pointer is not NULL. */ |
| 1331 | configASSERT( ( pxQueue ) ); |
| 1332 | |
| 1333 | /* The buffer into which data is received can only be NULL if the data size |
| 1334 | * is zero (so no data is copied into the buffer). */ |
| 1335 | configASSERT( !( ( ( pvBuffer ) == NULL ) && ( ( pxQueue )->uxItemSize != ( UBaseType_t ) 0U ) ) ); |
| 1336 | |
| 1337 | /* Cannot block if the scheduler is suspended. */ |
| 1338 | #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) |
| 1339 | { |
| 1340 | configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); |
| 1341 | } |
| 1342 | #endif |
| 1343 | |
| 1344 | /*lint -save -e904 This function relaxes the coding standard somewhat to |
| 1345 | * allow return statements within the function itself. This is done in the |
| 1346 | * interest of execution time efficiency. */ |
| 1347 | for( ; ; ) |
| 1348 | { |
| 1349 | taskENTER_CRITICAL(); |
| 1350 | { |
| 1351 | const UBaseType_t uxMessagesWaiting = pxQueue->uxMessagesWaiting; |
| 1352 | |
| 1353 | /* Is there data in the queue now? To be running the calling task |
| 1354 | * must be the highest priority task wanting to access the queue. */ |
| 1355 | if( uxMessagesWaiting > ( UBaseType_t ) 0 ) |
| 1356 | { |
| 1357 | /* Data available, remove one item. */ |
| 1358 | prvCopyDataFromQueue( pxQueue, pvBuffer ); |
| 1359 | traceQUEUE_RECEIVE( pxQueue ); |
| 1360 | pxQueue->uxMessagesWaiting = uxMessagesWaiting - ( UBaseType_t ) 1; |
| 1361 | |
| 1362 | /* There is now space in the queue, were any tasks waiting to |
| 1363 | * post to the queue? If so, unblock the highest priority waiting |
| 1364 | * task. */ |
| 1365 | if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) |
| 1366 | { |
| 1367 | if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) |
| 1368 | { |
| 1369 | queueYIELD_IF_USING_PREEMPTION(); |
| 1370 | } |
| 1371 | else |
| 1372 | { |
| 1373 | mtCOVERAGE_TEST_MARKER(); |
| 1374 | } |
| 1375 | } |
| 1376 | else |
| 1377 | { |
| 1378 | mtCOVERAGE_TEST_MARKER(); |
| 1379 | } |
no test coverage detected