Skip to content

Commit 7315355

Browse files
committed
Make mailbox_remove_message an inline function
mailbox_remove_message just calls a couple of functions. Signed-off-by: Davide Bettio <[email protected]>
1 parent 3ff5ada commit 7315355

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/libAtomVM/mailbox.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,6 @@ MailboxMessage *mailbox_take_message(Mailbox *mbox)
399399
return removed;
400400
}
401401

402-
void mailbox_remove_message(Mailbox *mbox, Heap *heap)
403-
{
404-
MailboxMessage *removed = mailbox_take_message(mbox);
405-
if (LIKELY(removed != NULL)) {
406-
mailbox_message_dispose(removed, heap);
407-
}
408-
}
409-
410402
Message *mailbox_first(Mailbox *mbox)
411403
{
412404
mailbox_reset(mbox);

src/libAtomVM/mailbox.h

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern "C" {
3838
#include "list.h"
3939
#include "smp.h"
4040
#include "term_typedef.h"
41+
#include "utils.h"
4142

4243
struct Context;
4344

@@ -273,16 +274,6 @@ bool mailbox_peek(Context *ctx, term *out);
273274
*/
274275
MailboxMessage *mailbox_take_message(Mailbox *mbox);
275276

276-
/**
277-
* @brief Remove next message from mailbox.
278-
*
279-
* @details Discard a term that has been previously queued on a certain process
280-
* or driver mailbox. To be called from the process only. Term messages are
281-
* actually added as fragments to the heap and will be gone at next GC.
282-
* @param mbx the mailbox to remove next message from.
283-
*/
284-
void mailbox_remove_message(Mailbox *mbox, Heap *ctx);
285-
286277
/**
287278
* @brief Get first message from mailbox.
288279
*
@@ -314,6 +305,22 @@ void mailbox_destroy(Mailbox *mbox, Heap *heap);
314305
*/
315306
void mailbox_message_dispose(MailboxMessage *m, Heap *heap);
316307

308+
/**
309+
* @brief Remove next message from mailbox.
310+
*
311+
* @details Discard a term that has been previously queued on a certain process
312+
* or driver mailbox. To be called from the process only. Term messages are
313+
* actually added as fragments to the heap and will be gone at next GC.
314+
* @param mbx the mailbox to remove next message from.
315+
*/
316+
static inline void mailbox_remove_message(Mailbox *mbox, Heap *heap)
317+
{
318+
MailboxMessage *removed = mailbox_take_message(mbox);
319+
if (LIKELY(removed != NULL)) {
320+
mailbox_message_dispose(removed, heap);
321+
}
322+
}
323+
317324
/**
318325
* @brief Output mailbox to stderr for crashdump reporting.
319326
*

0 commit comments

Comments
 (0)