summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-07-02 22:41:16 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-11-10 19:21:05 +1300
commit4b8903421828cb9d4de139180563ae8d8f04e1ab (patch)
tree21a0d02ba22afad6a4ce1c042acf6d74767dc5a2 /doc
parent56b90cf94465ce347a3d9a779363c78ce3deb180 (diff)
IO::Buffer for scheduler interface.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4621
Diffstat (limited to 'doc')
-rw-r--r--doc/fiber.md24
1 files changed, 23 insertions, 1 deletions
diff --git a/doc/fiber.md b/doc/fiber.md
index 9baab4e4d1..f0785d8ae6 100644
--- a/doc/fiber.md
+++ b/doc/fiber.md
@@ -48,6 +48,14 @@ When the thread exits, there is an implicit call to `set_scheduler`:
Fiber.set_scheduler(nil)
```
+### Design
+
+The scheduler interface is designed to be a un-opinionated light-weight layer
+between user code and blocking operations. The scheduler hooks should avoid
+translating or converting arguments or return values. Ideally, the exact same
+arguments from the user code are provided directly to the scheduler hook with
+no changes.
+
### Interface
This is the interface you need to implement.
@@ -65,7 +73,7 @@ class Scheduler
end.value
end
- # Wait for the given file descriptor to match the specified events within
+ # Wait for the given io readiness to match the specified events within
# the specified timeout.
# @parameter event [Integer] A bit mask of `IO::READABLE`,
# `IO::WRITABLE` and `IO::PRIORITY`.
@@ -74,6 +82,20 @@ class Scheduler
def io_wait(io, events, timeout)
end
+ # Read from the given io into the specified buffer.
+ # @parameter io [IO] The io to read from.
+ # @parameter buffer [IO::Buffer] The buffer to read into.
+ # @parameter length [Integer] The minimum amount to read.
+ def io_read(io, buffer, length)
+ end
+
+ # Write from the given buffer into the specified IO.
+ # @parameter io [IO] The io to write to.
+ # @parameter buffer [IO::Buffer] The buffer to write from.
+ # @parameter length [Integer] The minimum amount to write.
+ def io_write(io, buffer, length)
+ end
+
# Sleep the current task for the specified duration, or forever if not
# specified.
# @parameter duration [Numeric] The amount of time to sleep in seconds.