-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Implement a variation of the fiber interface that offers symmetric switching. The WasmFX instantiation of the interface should take advantage of the switch instruction.
I think something like the following will do:
/** The abstract type of a fiber object. **/
typedef struct fiber* fiber_t;
/** The signature of a fiber entry point. **/
typedef void* (*fiber_entry_point_t)(fiber_t, void*);
/** Allocates a new fiber with the default stack size. **/
export("fiber_alloc")
fiber_t fiber_alloc(fiber_entry_point_t entry);
/** Reclaims the memory occupied by the fiber object. **/
export("fiber_free")
void fiber_free(fiber_t fiber);
/** Possible status codes for `fiber_resume`. **/
typedef enum { FIBER_OK = 0, FIBER_YIELD = 1, FIBER_ERROR = 2 } fiber_result_t;
/** Yields control to the given target. This function must be called
from within a fiber context. **/
export("fiber_switch")
fiber_result_t fiber_switch(fiber_t target, void *arg);
/** Initialises the fiber runtime context. **/
export("fiber_main")
int fiber_main(int (*main)(int, char**), int, char**);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels