summaryrefslogtreecommitdiff
path: root/src/pulp.c
AgeCommit message (Collapse)Author
2018-05-16libpulp: experimental considerations for OSXVito Caputo
I don't have an OSX system to test with, but after some digging this looks like it might suffice.
2018-05-16libpulp: waking note in pulp_fiber_get_mailslot()Vito Caputo
2018-05-16libpulp: add win32 supportVito Caputo
This adds a rudimentary win32 implementation based on the fibers system API. It seems to work reasonably under wine when built w/mingw32.
2018-05-13libpulp: introduce mailbox conceptVito Caputo
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.
2018-05-13libpulp: add pulp_self() current fiber accessorVito Caputo
Analogous to pthread_self()
2018-05-03libpulp: move expire_alarms() to pulp_tick() beginVito Caputo
Expiring alarms of sleeping fibers in pulp_schedule() has the potential to prevent pulp_tick() from ever returning if there's always another fiber expiring @ schedule. In order to allow simple integration with external event loops, pulp_tick() is supposed to operate on what is essentially a slice of runnable fibers then immediately return control to the caller.
2018-05-02*: initial commit of libpulpVito Caputo
libpulp is a very basic cooperatively-scheduled userspace threading library. It refers to the userspace threads as fibers, and uses my other little library libthunk to bind the functions and their calling environment into tidy little structures having a uniform calling convention. At this time there's no build system or anything of the sort, it's early days and I'll probably be submoduling this into another project for direct inclusion and compilation.
© All Rights Reserved