main-apidocs-libatomvm-src-mailbox-dot-c.md
Include dependency graph for mailbox.c:
digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "19" [label="atom.h" tooltip="atom.h"] "20" [label="atom_table.h" tooltip="atom_table.h"] "33" [label="bitstring.h" tooltip="bitstring.h"] "17" [label="context.h" tooltip="context.h"] "15" [label="erl_nif.h" tooltip="erl_nif.h"] "21" [label="ets.h" tooltip="ets.h"] "35" [label="exportedfunction.h" tooltip="exportedfunction.h"] "18" [label="globalcontext.h" tooltip="globalcontext.h"] "27" [label="intn.h" tooltip="intn.h"] "32" [label="jit.h" tooltip="jit.h"] "4" [label="list.h" tooltip="list.h"] "1" [label="/__w/AtomVM/AtomVM/src/libAtomVM/mailbox.c" tooltip="/__w/AtomVM/AtomVM/src/libAtomVM/mailbox.c" fillcolor="#BFBFBF"] "2" [label="mailbox.h" tooltip="mailbox.h"] "14" [label="memory.h" tooltip="memory.h"] "28" [label="refc_binary.h" tooltip="refc_binary.h"] "29" [label="resources.h" tooltip="resources.h"] "16" [label="scheduler.h" tooltip="scheduler.h"] "23" [label="smp.h" tooltip="smp.h"] "22" [label="synclist.h" tooltip="synclist.h"] "24" [label="term.h" tooltip="term.h"] "5" [label="term_typedef.h" tooltip="term_typedef.h"] "30" [label="timer_list.h" tooltip="timer_list.h"] "36" [label="trace.h" tooltip="trace.h"] "34" [label="unicode.h" tooltip="unicode.h"] "10" [label="utils.h" tooltip="utils.h"] "31" [label="valueshashtable.h" tooltip="valueshashtable.h"] "6" [label="assert.h" tooltip="assert.h"] "8" [label="inttypes.h" tooltip="inttypes.h"] "7" [label="limits.h" tooltip="limits.h"] "3" [label="stdbool.h" tooltip="stdbool.h"] "11" [label="stddef.h" tooltip="stddef.h"] "9" [label="stdint.h" tooltip="stdint.h"] "12" [label="stdio.h" tooltip="stdio.h"] "13" [label="stdlib.h" tooltip="stdlib.h"] "26" [label="string.h" tooltip="string.h"] "25" [label="sys/types.h" tooltip="sys/types.h"] "19" -> "9" [dir=forward tooltip="include"] "19" -> "13" [dir=forward tooltip="include"] "20" -> "3" [dir=forward tooltip="include"] "20" -> "19" [dir=forward tooltip="include"] "20" -> "10" [dir=forward tooltip="include"] "33" -> "27" [dir=forward tooltip="include"] "33" -> "24" [dir=forward tooltip="include"] "33" -> "34" [dir=forward tooltip="include"] "33" -> "3" [dir=forward tooltip="include"] "33" -> "9" [dir=forward tooltip="include"] "17" -> "18" [dir=forward tooltip="include"] "17" -> "32" [dir=forward tooltip="include"] "17" -> "4" [dir=forward tooltip="include"] "17" -> "2" [dir=forward tooltip="include"] "17" -> "23" [dir=forward tooltip="include"] "17" -> "24" [dir=forward tooltip="include"] "17" -> "30" [dir=forward tooltip="include"] "15" -> "5" [dir=forward tooltip="include"] "21" -> "3" [dir=forward tooltip="include"] "21" -> "22" [dir=forward tooltip="include"] "21" -> "24" [dir=forward tooltip="include"] "35" -> "24" [dir=forward tooltip="include"] "18" -> "9" [dir=forward tooltip="include"] "18" -> "19" [dir=forward tooltip="include"] "18" -> "20" [dir=forward tooltip="include"] "18" -> "15" [dir=forward tooltip="include"] "18" -> "21" [dir=forward tooltip="include"] "18" -> "4" [dir=forward tooltip="include"] "18" -> "2" [dir=forward tooltip="include"] "18" -> "23" [dir=forward tooltip="include"] "18" -> "22" [dir=forward tooltip="include"] "18" -> "24" [dir=forward tooltip="include"] "18" -> "30" [dir=forward tooltip="include"] "18" -> "31" [dir=forward tooltip="include"] "27" -> "3" [dir=forward tooltip="include"] "27" -> "26" [dir=forward tooltip="include"] "27" -> "10" [dir=forward tooltip="include"] "32" -> "33" [dir=forward tooltip="include"] "32" -> "35" [dir=forward tooltip="include"] "32" -> "24" [dir=forward tooltip="include"] "32" -> "5" [dir=forward tooltip="include"] "32" -> "3" [dir=forward tooltip="include"] "4" -> "3" [dir=forward tooltip="include"] "1" -> "2" [dir=forward tooltip="include"] "1" -> "11" [dir=forward tooltip="include"] "1" -> "14" [dir=forward tooltip="include"] "1" -> "16" [dir=forward tooltip="include"] "1" -> "22" [dir=forward tooltip="include"] "1" -> "36" [dir=forward tooltip="include"] "2" -> "3" [dir=forward tooltip="include"] "2" -> "4" [dir=forward tooltip="include"] "2" -> "5" [dir=forward tooltip="include"] "2" -> "10" [dir=forward tooltip="include"] "14" -> "9" [dir=forward tooltip="include"] "14" -> "13" [dir=forward tooltip="include"] "14" -> "15" [dir=forward tooltip="include"] "14" -> "5" [dir=forward tooltip="include"] "14" -> "10" [dir=forward tooltip="include"] "28" -> "3" [dir=forward tooltip="include"] "28" -> "13" [dir=forward tooltip="include"] "28" -> "4" [dir=forward tooltip="include"] "28" -> "29" [dir=forward tooltip="include"] "29" -> "13" [dir=forward tooltip="include"] "29" -> "15" [dir=forward tooltip="include"] "29" -> "4" [dir=forward tooltip="include"] "29" -> "2" [dir=forward tooltip="include"] "29" -> "14" [dir=forward tooltip="include"] "29" -> "22" [dir=forward tooltip="include"] "16" -> "17" [dir=forward tooltip="include"] "16" -> "18" [dir=forward tooltip="include"] "23" -> "3" [dir=forward tooltip="include"] "22" -> "12" [dir=forward tooltip="include"] "22" -> "4" [dir=forward tooltip="include"] "22" -> "23" [dir=forward tooltip="include"] "24" -> "25" [dir=forward tooltip="include"] "24" -> "3" [dir=forward tooltip="include"] "24" -> "9" [dir=forward tooltip="include"] "24" -> "12" [dir=forward tooltip="include"] "24" -> "13" [dir=forward tooltip="include"] "24" -> "26" [dir=forward tooltip="include"] "24" -> "19" [dir=forward tooltip="include"] "24" -> "27" [dir=forward tooltip="include"] "24" -> "14" [dir=forward tooltip="include"] "24" -> "28" [dir=forward tooltip="include"] "24" -> "29" [dir=forward tooltip="include"] "24" -> "10" [dir=forward tooltip="include"] "24" -> "5" [dir=forward tooltip="include"] "5" -> "6" [dir=forward tooltip="include"] "5" -> "7" [dir=forward tooltip="include"] "5" -> "8" [dir=forward tooltip="include"] "5" -> "9" [dir=forward tooltip="include"] "30" -> "3" [dir=forward tooltip="include"] "30" -> "9" [dir=forward tooltip="include"] "30" -> "4" [dir=forward tooltip="include"] "34" -> "3" [dir=forward tooltip="include"] "34" -> "11" [dir=forward tooltip="include"] "34" -> "9" [dir=forward tooltip="include"] "10" -> "8" [dir=forward tooltip="include"] "10" -> "3" [dir=forward tooltip="include"] "10" -> "11" [dir=forward tooltip="include"] "10" -> "12" [dir=forward tooltip="include"] "10" -> "13" [dir=forward tooltip="include"] "31" -> "11" [dir=forward tooltip="include"] "31" -> "9" [dir=forward tooltip="include"] }
Defines
ADDITIONAL_PROCESSING_MEMORY_SIZE 4
Functions
void mailbox_init(Mailbox *mbx)
Initialize the mailbox.
Parameters:
HeapFragment *mailbox_message_to_heap_fragment(void *m, term *heap_end)
void mailbox_message_dispose(MailboxMessage *m, Heap *heap)
Dispose a (processed) mailbox message. The message will be freed or appended to current heap and will be destroyed on garbage collect. This function is called by mailbox_remove and is only needed for signal messages.
Parameters:
m – the message to free.
heap – heap to append the message to.
void mailbox_message_dispose_unsent(Message *m, GlobalContext *global, bool from_task)
Dispose an unsent normal message. The message will be freed.
Parameters:
m – the message to dispose.
global – the global context
from_task – boolean, true if called from a task, false otherwise
void mailbox_destroy(Mailbox *mbox, Heap *heap)
Free memory associated with a mailbox.
All messages in the mailbox will be freed or appended to the heap.
Parameters:
mbox – the mailbox to free.
heap – the heap to add messages to.
size_t mailbox_len(Mailbox *mbox)
Compute the mailbox length, in messages.
To be called from the process only.
Parameters:
size_t mailbox_size(Mailbox *mbox)
Compute the mailbox size, in bytes.
To be called from the process only.
Parameters:
inline void mailbox_enqueue_message(Context *c, MailboxMessage *m)
Enqueue message.
This function does not signal the process to be ready and is only meant to be called from a task by globalcontext_send_message_from_task.
Parameters:
c – the process context.
m – the message to enqueue
void mailbox_post_message(Context *c, MailboxMessage *m)
Post a message.
Post a message to a given context. Context gets ownership of the created message.
Parameters:
c – the process context.
m – the mailbox message to send
MailboxMessage *mailbox_message_create_from_term(enum MessageType type, term t)
Allocate and serialize a term to a mailbox message.
Can be called from a task or even ISR (provided malloc works).
Parameters:
type – the message type, can be NormalMessage or a signal type
t – the term that will be sent
Message *mailbox_message_create_normal_message_from_term(term t)
Allocate and serialize a term to a normal message.
Can be called from a task or even ISR (provided malloc works).
Parameters:
void mailbox_send(Context *c, term t)
Sends a message to a certain mailbox.
Sends a term to a certain process or port mailbox. Can be called from another process. Cannot be called from a task or from ISR.
Parameters:
c – the process context.
t – the term that will be sent.
void mailbox_send_term_signal(Context *c, enum MessageType type, term t)
Sends a term-based signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
t – the term added to the message
void mailbox_send_immediate_signal(Context *c, enum MessageType type, term immediate)
Sends an immediate signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
immediate – the immediate term to send (atom or pid)
void mailbox_send_built_in_atom_request_signal(Context *c, enum MessageType type, int32_t pid, term atom)
Sends a built-in atom-based request signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
sender_pid – the sender of the signal (to get the answer)
atom – the built-in atom
void mailbox_send_ref_signal(Context *c, enum MessageType type, uint64_t ref_ticks)
Sends a ref signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
ref_ticks – the ref
void mailbox_send_immediate_ref_signal(Context *c, enum MessageType type, term immediate, uint64_t ref_ticks)
Sends an immediate and ref signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
immediate – the immediate term to send (atom or pid)
ref_ticks – the ref
void mailbox_send_monitor_signal(Context *c, enum MessageType type, struct Monitor *monitor)
Sends a ref immediate signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
monitor – the monitor
void mailbox_send_empty_body_signal(Context *c, enum MessageType type)
Sends an empty body signal to a certain mailbox.
Parameters:
c – the process context.
type – the type of the signal
void mailbox_reset(Mailbox *mbox)
Reset mailbox receive pointer.
To be called from the process only.
Parameters:
MailboxMessage *mailbox_process_outer_list(Mailbox *mbox)
Process the outer list of messages.
To be called from the process only
Parameters:
Returns:
the signal messages in received order.
void mailbox_next(Mailbox *mbox)
Advance pointer to next message in a receive loop.
To be called from the process only.
Parameters:
bool mailbox_peek(Context *c, term *out)
Gets next message from a mailbox (without removing it).
Peek the mailbox and retrieve a term that has been previously queued on a certain process or driver mailbox. To be called from the process only.
Parameters:
ctx – the calling context, owning the mailbox and where the message should be copied to.
out – the allocated term.
Returns:
true if a term was available
MailboxMessage *mailbox_take_message(Mailbox *mbox)
Take next message from mailbox.
Remove the first message from the mailbox and return it. To be called from the process only. This function is intended for some corner cases, such as certain port drivers.
Parameters:
Message *mailbox_first(Mailbox *mbox)
Get first message from mailbox.
Get the first message and sets the receive pointer to it so it can be removed later. Used by ports & drivers. To be called from the process only.
Parameters:
Returns:
first message or NULL.
void mailbox_crashdump(Context *ctx)
Output mailbox to stderr for crashdump reporting.
Parameters: