MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_data_queue_len

Function rt_data_queue_len

components/drivers/ipc/dataqueue.c:432–459  ·  view source on GitHub ↗

* @brief This function will get the number of data in the data queue. * * @param queue is a pointer to the data queue object. * * @return Return the number of data in the data queue. */

Source from the content-addressed store, hash-verified

430 * @return Return the number of data in the data queue.
431 */
432rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
433{
434 rt_base_t level;
435 rt_int16_t len;
436
437 RT_ASSERT(queue != RT_NULL);
438 RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
439
440 if (queue->is_empty)
441 {
442 return 0;
443 }
444
445 level = rt_spin_lock_irqsave(&(queue->spinlock));
446
447 if (queue->put_index > queue->get_index)
448 {
449 len = queue->put_index - queue->get_index;
450 }
451 else
452 {
453 len = queue->size + queue->put_index - queue->get_index;
454 }
455
456 rt_spin_unlock_irqrestore(&(queue->spinlock), level);
457
458 return len;
459}
460RTM_EXPORT(rt_data_queue_len);
461

Callers 1

rt_data_queue_popFunction · 0.85

Calls 2

rt_spin_lock_irqsaveFunction · 0.50

Tested by

no test coverage detected