Name

SPVM::Go::Schedule - Goroutine Scheduler

Description

Go::Schedule class in SPVM is a goroutine scheduler.

Usage

my $schedule = Go->schedule;

$shcedule->run;

Fields

uv_loop

has uv_loop : ro UV::Loop;

An event loop.

Instance Methods

enable_goroutine

method enable_goroutine : void ($goroutine : Go::Goroutine);

Enables $goroutine, removes it from disabled_goroutines_h, and pushes it to enabled_goroutines.

disable_current_goroutine

method disable_current_goroutine : Go::Goroutine ();

Disables the current goroutine and returns it. If current_goroutine is not set, creates a no-op goroutine and adds it to enabled_goroutines first.

run

method run : void ();

Transfers control back to main_goroutine if already running, or starts the event loop and schedules goroutines.

Exceptions:

This method must be called from the main thread. Otherwise an exception is thrown.

go

method go : void ($task : Callback, $caller_info : CallerInfo);

Schedules a goroutine with $task and $caller_info.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License