Added new chThdDoDequeueNextI() API.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7286 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2014-09-17 10:37:54 +00:00
parent 7fa620e9fb
commit 227f9b7e3e
2 changed files with 29 additions and 18 deletions

View File

@ -393,6 +393,31 @@ static inline bool chThdQueueIsEmptyI(threads_queue_t *tqp) {
return queue_isempty(tqp); return queue_isempty(tqp);
} }
/**
* @brief Dequeues and wakes up one thread from the threads queue object.
* @details Dequeues one thread from the queue without checking if the queue
* is empty.
* @pre The queue must contain at least an object.
*
* @param[in] tqp pointer to the threads queue object
* @param[in] msg the message code
*
* @iclass
*/
static inline void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg) {
thread_t *tp;
chDbgAssert(queue_notempty(tqp), "empty queue");
tp = queue_fifo_remove(tqp);
chDbgAssert(tp->p_state == CH_STATE_QUEUED, "invalid state");
tp->p_u.rdymsg = msg;
chSchReadyI(tp);
}
#endif /* _CHTHREADS_H_ */ #endif /* _CHTHREADS_H_ */
/** @} */ /** @} */

View File

@ -640,15 +640,8 @@ msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, systime_t timeout) {
*/ */
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg) { void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg) {
if (queue_notempty(tqp)) { if (queue_notempty(tqp))
thread_t *tp = queue_fifo_remove(tqp); chThdDoDequeueNextI(tqp, msg);
chDbgAssert(tp->p_state == CH_STATE_QUEUED,
"not CH_STATE_QUEUED");
tp->p_u.rdymsg = msg;
chSchReadyI(tp);
}
} }
/** /**
@ -661,15 +654,8 @@ void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg) {
*/ */
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg) { void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg) {
while (queue_notempty(tqp)) { while (queue_notempty(tqp))
thread_t *tp = queue_fifo_remove(tqp); chThdDoDequeueNextI(tqp, msg);
chDbgAssert(tp->p_state == CH_STATE_QUEUED,
"not CH_STATE_QUEUED");
tp->p_u.rdymsg = msg;
chSchReadyI(tp);
}
} }
/** @} */ /** @} */