-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Kernel.sleep calling the Fiber scheduler hook
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module FiberSpecs | ||
|
||
class LoggingScheduler | ||
attr_reader :events | ||
def initialize | ||
@events = [] | ||
end | ||
|
||
def block(*args) | ||
@events << { event: :block, fiber: Fiber.current, args: args } | ||
Fiber.yield | ||
end | ||
|
||
def io_wait(*args) | ||
@events << { event: :io_wait, fiber: Fiber.current, args: args } | ||
Fiber.yield | ||
end | ||
|
||
def kernel_sleep(*args) | ||
@events << { event: :kernel_sleep, fiber: Fiber.current, args: args } | ||
Fiber.yield | ||
end | ||
|
||
def unblock(*args) | ||
@events << { event: :unblock, fiber: Fiber.current, args: args } | ||
Fiber.yield | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters