Skip to content

Commit

Permalink
Improve code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
larskanis committed Sep 5, 2024
1 parent 60f74ff commit 65c5031
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/helpers/tcp_gate_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def read( transfer_until: )
# Option `transfer_until` can be (higher to lower priority):
# :eof => transfer until channel is closed
# :wouldblock => transfer until no immediate data is available
# IO object => transfer until IO is writeable
# IO object => transfer until IO is writable
#
# The method does nothing if a transfer is already pending, but might raise the transfer_until option, if the requested priority is higher than the pending transfer.
def write( transfer_until: )
Expand Down Expand Up @@ -282,7 +282,7 @@ def io_wait(io, events, duration)
conn.observed_fd = io.fileno

if (events & IO::WRITABLE) > 0
puts "write-trigger #{conn.write_fds} until #{io.fileno} writeable"
puts "write-trigger #{conn.write_fds} until #{io.fileno} writable"
conn.write(transfer_until: io)

if (events & IO::READABLE) > 0
Expand All @@ -292,10 +292,10 @@ def io_wait(io, events, duration)
else
if (events & IO::READABLE) > 0
puts "write-trigger #{conn.write_fds} until wouldblock"
# Many applications wait for writablility only in a would-block case.
# Then we get no trigger although data was written to the observed IO.
# After writing some data the caller usually waits for some answer to read.
# We take this event as a trigger to transfer of all pending written data.
# libpq waits for writablility only in a would-block case and not before writing.
# Since our incoming IO probably doesn't block, we get no write-trigger although data was written to the observed IO.
# But after writing some data the caller usually waits for some answer to read.
# We take this event as a trigger to transfer all pending written data.
conn.write(transfer_until: :wouldblock)

puts "read-trigger #{conn.read_fds} single block"
Expand Down

0 comments on commit 65c5031

Please sign in to comment.