Module scheduler

Module scheduler 

Source
Expand description

Scheduler - Green Thread Management with May

CSP-style concurrency for Seq using May coroutines. Each strand is a lightweight green thread that can communicate via channels.

§Non-Blocking Guarantee

Channel operations (send, receive) use May’s cooperative blocking and NEVER block OS threads. However, I/O operations (write_line, read_line in io.rs) currently use blocking syscalls. Future work will make all I/O non-blocking.

§Panic Behavior

Functions panic on invalid input (null stacks, negative IDs, closed channels). In a production system, consider implementing error channels or Result-based error handling instead of panicking.

Re-exports§

pub use patch_seq_scheduler_init as scheduler_init;
pub use patch_seq_scheduler_run as scheduler_run;
pub use patch_seq_scheduler_shutdown as scheduler_shutdown;
pub use patch_seq_spawn_strand as spawn_strand;
pub use patch_seq_strand_spawn as strand_spawn;
pub use patch_seq_wait_all_strands as wait_all_strands;
pub use patch_seq_yield_strand as yield_strand;

Structs§

StrandRegistry
Lock-free strand registry
StrandSlot
A slot in the strand registry

Statics§

ACTIVE_STRANDS
PEAK_STRANDS
TOTAL_COMPLETED
TOTAL_SPAWNED

Functions§

patch_seq_scheduler_init
Initialize the scheduler
patch_seq_scheduler_run
Run the scheduler and wait for all coroutines to complete
patch_seq_scheduler_shutdown
Shutdown the scheduler
patch_seq_spawn_strand
Legacy spawn_strand function (kept for compatibility)
patch_seq_strand_spawn
Spawn a strand (coroutine) with initial stack
patch_seq_wait_all_strands
Wait for all strands to complete
patch_seq_yield_strand
Yield execution to allow other coroutines to run
strand_registry
Get or initialize the global strand registry