mailbox.h
Include dependency graph for mailbox.h:
This graph shows which files directly or indirectly include mailbox.h:
Mailbox management functions such as send and receive functions.
Mailbox management functions should be used to send messages to a certain process or port and to receive them.
Enums
Functions
-
void mailbox_init(Mailbox *mbox)
Initialize the mailbox.
- Parameters:
mbox – the mailbox to initialize.
-
size_t mailbox_len(Mailbox *mbox)
Compute the mailbox length, in messages.
To be called from the process only.
- Parameters:
mbox – the mailbox to get the length of.
-
size_t mailbox_size(Mailbox *mbox)
Compute the mailbox size, in bytes.
To be called from the process only.
- Parameters:
mbox – the mailbox to get the size of.
-
MailboxMessage *mailbox_process_outer_list(Mailbox *mbox)
Process the outer list of messages.
To be called from the process only
- Parameters:
mbox – the mailbox to work with
- Returns:
the signal messages in received order.
-
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.
- 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_built_in_atom_signal(Context *c, enum MessageType type, term atom)
Sends a built-in atom signal to a certain mailbox.
- Parameters:
c – the process context.
type – the type of the signal
atom – the built-in atom
-
void mailbox_send_built_in_atom_request_signal(Context *c, enum MessageType type, int32_t sender_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_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:
mbox – the mailbox to work with
-
void mailbox_next(Mailbox *mbox)
Advance pointer to next message in a receive loop.
To be called from the process only.
- Parameters:
mbox – the mailbox to work with
-
static inline bool mailbox_has_next(Mailbox *mbox)
Determine if there is a next item in message list.
To be called from the process only.
- Parameters:
mbox – the mailbox to test
- Returns:
true
if peek would succeed.
-
bool mailbox_peek(Context *ctx, 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:
mbox – the mailbox to take the next message from.
-
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:
mbox – the mailbox to get the current message from.
- Returns:
first message or NULL.
-
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.
-
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.
-
static inline void mailbox_remove_message(Mailbox *mbox, Heap *heap)
Remove next message from mailbox.
Discard a term that has been previously queued on a certain process or driver mailbox. To be called from the process only. Term messages are actually added as fragments to the heap and will be gone at next GC.
- Parameters:
mbox – the mailbox to remove next message from.
heap – the heap to add messages to.
-
void mailbox_crashdump(Context *ctx)
Output mailbox to stderr for crashdump reporting.
- Parameters:
ctx – the owner of the mailbox to dump
-
struct MailboxMessage
- #include <mailbox.h>
Collaboration diagram for MailboxMessage:
Public Members
-
MailboxMessage *next
-
enum MessageType type
-
union MailboxMessage.[anonymous] [anonymous]
-
MailboxMessage *next
-
struct Message
- #include <mailbox.h>
Collaboration diagram for Message:
-
struct TermSignal
- #include <mailbox.h>
Collaboration diagram for TermSignal:
-
struct BuiltInAtomSignal
- #include <mailbox.h>
Collaboration diagram for BuiltInAtomSignal:
-
struct BuiltInAtomRequestSignal
- #include <mailbox.h>
Collaboration diagram for BuiltInAtomRequestSignal:
-
struct RefSignal
- #include <mailbox.h>
Collaboration diagram for RefSignal:
-
struct Mailbox
- #include <mailbox.h>
Collaboration diagram for Mailbox:
Public Members
- MailboxMessage *ATOMIC outer_first
-
MailboxMessage *inner_first
-
MailboxMessage *inner_last
-
MailboxMessage *receive_pointer
-
MailboxMessage *receive_pointer_prev