Skip to content

Commit 8902a85

Browse files
committed
Rationalise Queue/Mail get/put APIs
To line up with MemoryPool/Mail alloc, rework naming of get/put Queue::get -> try_get, try_get_for Queue::put -> try_put, try_put_for Mail::get -> try_get, try_get_for Mail::put (no change, but assert that it works) In the future the names `get` and `put` can be used for untimed blocking operations. In the interim, you have to use `try_get_for(Kernel::wait_for_u32_forever)`. `Mail::put` differs in that it has always been a non-blocking call, but it can be assumed to always succeed when used correctly, because the Queue has enough room to store a pointer to every block in the MemoryPool. It could in future be made a `void` return, similar to the change made to `Mutex::lock`.
1 parent 8030c11 commit 8902a85

File tree

1 file changed

+3
-3
lines changed
  • TESTS/mbedmicro-rtos-mbed/threads

1 file changed

+3
-3
lines changed

TESTS/mbedmicro-rtos-mbed/threads/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,12 @@ void test_msg_get()
705705

706706
TEST_ASSERT_EQUAL(Thread::WaitingMessageGet, t.get_state());
707707

708-
queue.put((int32_t *)0xE1EE7);
708+
queue.try_put((int32_t *)0xE1EE7);
709709
}
710710

711711
void test_msg_put_thread(Queue<int32_t, 1> *queue)
712712
{
713-
queue->put((int32_t *)0xDEADBEEF, Kernel::wait_for_u32_forever);
713+
queue->try_put_for(Kernel::wait_for_u32_forever, (int32_t *)0xDEADBEEF);
714714

715715
}
716716

@@ -729,7 +729,7 @@ void test_msg_put()
729729
Thread t(osPriorityNormal, THREAD_STACK_SIZE);
730730
Queue<int32_t, 1> queue;
731731

732-
queue.put((int32_t *)0xE1EE7);
732+
queue.try_put((int32_t *)0xE1EE7);
733733

734734
t.start(callback(test_msg_put_thread, &queue));
735735

0 commit comments

Comments
 (0)