Skip to content

Commit

Permalink
Simplify implementation of scheduler io_read and io_write. (#6527)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 12, 2022
1 parent 4e29ca0 commit 04d291a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/fiber/scheduler.rb
Expand Up @@ -269,15 +269,14 @@ def io_read(io, buffer, length, offset)
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
Expand All @@ -298,15 +297,14 @@ def io_write(io, buffer, length, offset)
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
Expand Down

0 comments on commit 04d291a

Please sign in to comment.