[#82706] [Ruby trunk Bug#13851] getting "can't modify string; temporarily locked" on non-frozen instances — cardoso_tiago@...
Issue #13851 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/07
[#82853] [Ruby trunk Bug#13916] Race condition when sending a signal to a new fork — russell.davis@...
Issue #13916 has been reported by russelldavis (Russell Davis).
3 messages
2017/09/19
[#82892] [Ruby trunk Bug#13921] buffered read_nonblock doesn't work as expected using SSLSocket — cardoso_tiago@...
Issue #13921 has been updated by chucke (Tiago Cardoso).
3 messages
2017/09/20
[ruby-core:82967] [Ruby trunk Feature#11484][Feedback] add output offset for readpartial/read_nonblock/etc
From:
matz@...
Date:
2017-09-25 06:56:17 UTC
List:
ruby-core #82967
Issue #11484 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Feedback
I like the idea but do not like the name `off_out`. Any other candidate?
Matz.
----------------------------------------
Feature #11484: add output offset for readpartial/read_nonblock/etc
https://bugs.ruby-lang.org/issues/11484#change-66870
* Author: normalperson (Eric Wong)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
~~~
Specifying a destination offset will allow allocating less garbage
strings to improve performance when reading partial data off a pipe
or socket.
For example:
tmp = "".b
buf = "".b
case rv = io.read_nonblock(8192, tmp, exception: false)
when String
buf << tmp
break if parsing_done?(buf)
else
return rv
end while true
Can be written as:
buf = "".b
case rv = io.read_nonblock(8192, buf, exception: false, off_out: buf.size)
when String
break if parsing_done?(buf)
else
return rv
end while true
For reference, here is the relevant part from "perldoc -f sysread"
sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
sysread FILEHANDLE,SCALAR,LENGTH
-snip-
An OFFSET may be specified to place the read data at some place
in the string other than the beginning. A negative OFFSET
specifies placement at that many characters counting backwards
from the end of the string. A positive OFFSET greater than the
length of SCALAR results in the string being padded to the
required size with "\0" bytes before the result of the read is
appended.
-snip-
Maybe we can shortcut by allowing "off_out: :end" to avoid redundant
words and potentially using the wrong variable:
io.read_nonblock(8192, buf, exception: false, off_out: :end)
I'm not sure when I'll have time to work on this feature.
Lately I've been working in Perl again and rediscovered this API subtlety.
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>