summaryrefslogtreecommitdiff
path: root/src/example.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-05-13 23:42:23 -0700
committerVito Caputo <vcaputo@pengaru.com>2018-05-13 23:42:23 -0700
commit9e1c6fc49ce4127ff7aa8892a52d3ca8acdf1854 (patch)
tree5a05f6036a1cd64ff979028396a248bd5bae685b /src/example.c
parent149643c5638f39ba03a49b8483921ce53c643a4d (diff)
libpulp: introduce mailbox concept
The sleep functions, which are few, and the only current means for fibers to block/enter the scheduler, now take an optional pulp_mailbox_t * parameter. When supplied, other fibers may communicate with the sleeping fiber via pulp_fiber_get_mailslot(). This function checks the destination fiber for a mailbox and verifies there's space available. On success, it returns a pointer to the next available mailslot while advancing the mailboxes mail count. The caller may then use this mailslot pointer to write directly to the void * it references in the mailbox. If the receiving fiber took care to populate its mailbox with slots referencing external memory, the sender could dereference the mailslot's value to find the external memory and write larger messages without needing to allocate new space itself only for the reciever to have to free it shortly. It's also possible to not do anything at all with the mailslot. Simply successfully getting a mailslot communicates _something_ to the recipient by virtue of the count advancing. The returned mailslot can only be considered valid by the calling fiber until it sleeps, after that the slot must be treated as reclaimed from the perspective of the fiber that called pulp_fiber_get_mailslot(). When the sleeping fiber wakes and returns from its mailbox-enabled sleep call, it simply looks at the count member of the mailbox to see if any mail was received. It's up to the implementation what is done with the contents of the mailbox. The mailbox count is always reset to 0 automatically at the start of a mailbox-enabled sleep.
Diffstat (limited to 'src/example.c')
0 files changed, 0 insertions, 0 deletions
© All Rights Reserved