Skip to content

Add specs for Fiber.schedule and Fiber.current_scheduler - #1388

Merged
ioquatix merged 1 commit into
ruby:masterfrom
sampokuokkanen:fiber-schedule-specs
Aug 22, 2026
Merged

Add specs for Fiber.schedule and Fiber.current_scheduler#1388
ioquatix merged 1 commit into
ruby:masterfrom
sampokuokkanen:fiber-schedule-specs

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

Fiber.schedule and Fiber.current_scheduler had no specs. Cover the RuntimeError raised when no scheduler is set, that the scheduler's #fiber hook is called and its return value is what Fiber.schedule hands back, and that Fiber.schedule works from inside a non-blocking Fiber.

Fiber.current_scheduler returns the scheduler only when the current Fiber is non-blocking, which is what separates it from Fiber.scheduler. Cover the root Fiber, blocking and non-blocking Fibers,

Fiber.schedule and Fiber.current_scheduler had no specs. Cover the RuntimeError raised when no scheduler is set, that the scheduler's #fiber hook is called and its return value is what Fiber.schedule hands back, and that Fiber.schedule works from inside a non-blocking Fiber.

Fiber.current_scheduler returns the scheduler only when the current Fiber is non-blocking, which is what separates it from Fiber.scheduler. Cover the root Fiber, blocking and non-blocking Fibers,
@ioquatix
ioquatix merged commit f84b436 into ruby:master Aug 22, 2026
14 checks passed
sampokuokkanen added a commit to sampokuokkanen/jruby that referenced this pull request Aug 22, 2026
Fiber.schedule looked up the scheduler on the Fiber's carrier thread rather than the Thread that owns it, so calling it from inside a non-blocking Fiber raised "No scheduler is available!". Use getFiberCurrentThread(), like Fiber.scheduler and MRI's
rb_fiber_s_schedule.

Specs come from ruby/spec#1388 (merged) and three of the six fail without this. One is tagged for a separate blocking-count bug (passes when run in isolation but fails when run with other fiber tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants