File tree Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Expand file tree Collapse file tree 2 files changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -106,23 +106,26 @@ def sysclose
106106 end
107107 end
108108
109- def syswrite ( buffer )
110- # This fails due to re-entrancy issues with a concurrent call to `sysclose`.
111- # return @io.write(buffer)
112-
113- while true
114- result = @io . write_nonblock ( buffer , exception : false )
115-
116- case result
117- when :wait_readable
118- @io . wait_readable ( @io . timeout ) or raise ::IO ::TimeoutError , "read timeout"
119- when :wait_writable
120- @io . wait_writable ( @io . timeout ) or raise ::IO ::TimeoutError , "write timeout"
121- else
122- if result == buffer . bytesize
123- return
109+ if RUBY_VERSION >= "3.3"
110+ def syswrite ( buffer )
111+ return @io . write ( buffer )
112+ end
113+ else
114+ def syswrite ( buffer )
115+ while true
116+ result = @io . write_nonblock ( buffer , exception : false )
117+
118+ case result
119+ when :wait_readable
120+ @io . wait_readable ( @io . timeout ) or raise ::IO ::TimeoutError , "read timeout"
121+ when :wait_writable
122+ @io . wait_writable ( @io . timeout ) or raise ::IO ::TimeoutError , "write timeout"
124123 else
125- buffer = buffer . byteslice ( result , buffer . bytesize )
124+ if result == buffer . bytesize
125+ return
126+ else
127+ buffer = buffer . byteslice ( result , buffer . bytesize )
128+ end
126129 end
127130 end
128131 end
Original file line number Diff line number Diff line change 11# Releases
22
3+ ## Unreleased
4+
5+ - On Ruby v3.3+, use ` IO#write ` directly instead of ` IO#write_nonblock ` , for better performance.
6+
37## v0.7.0
48
59 - Split stream functionality into separate ` Readable ` and ` Writable ` modules for better modularity and composition.
You can’t perform that action at this time.
0 commit comments