summaryrefslogtreecommitdiff
path: root/test/fiber
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-10-12 15:56:35 +1300
committerGitHub <noreply@github.com>2022-10-12 15:56:35 +1300
commit04d291a490517eb32ea02df636fc8f1f1ed57873 (patch)
tree88c6b50e6907bdceaeeaf31feafc2d3dd6408fae /test/fiber
parent4e29ca0c4093133838eda852879b23ed4fad56b5 (diff)
downloadruby-04d291a490517eb32ea02df636fc8f1f1ed57873.tar.gz
Simplify implementation of scheduler `io_read` and `io_write`. (#6527)
Diffstat (limited to 'test/fiber')
-rw-r--r--test/fiber/scheduler.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb
index ceed606338..322564fe6d 100644
--- a/test/fiber/scheduler.rb
+++ b/test/fiber/scheduler.rb
@@ -269,15 +269,14 @@ class IOBufferScheduler < Scheduler
total = 0
io.nonblock = true
- while length >= 0
+ while true
maximum_size = buffer.size - offset
-
result = blocking{buffer.read(io, maximum_size, offset)}
if result > 0
total += result
offset += result
- break if result >= length
+ break if total >= length
elsif result == 0
break
elsif result == EAGAIN
@@ -298,15 +297,14 @@ class IOBufferScheduler < Scheduler
total = 0
io.nonblock = true
- while length >= 0
+ while true
maximum_size = buffer.size - offset
-
result = blocking{buffer.write(io, maximum_size, offset)}
if result > 0
total += result
offset += result
- break if result >= length
+ break if total >= length
elsif result == 0
break
elsif result == EAGAIN