Project

General

Profile

Feature #9323

IO#writev

Added by Glass_saga (Masaki Matsushita) over 3 years ago. Updated about 1 month ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
[ruby-core:59408]

Description

I propose addition of IO#writev.
It enables gather output from multiple buffers.
If writev(2) is not available, IO#writev uses Array#join to emulate atomic write.

patch.diff (7.83 KB) patch.diff Glass_saga (Masaki Matsushita), 12/30/2013 10:08 PM
patch.diff (6.28 KB) patch.diff Glass_saga (Masaki Matsushita), 06/27/2017 05:05 AM

History

#1 [ruby-core:60003] Updated by normalperson (Eric Wong) over 3 years ago

Unless we have use for it, I don't think rb_io_writev should be in
the C API, and even less reason for it to be public for extensions
in ruby/intern.h

Also, it'd probably be good to dedup the fptr->wbuf initialization
code in io_binwrite*.

Otherwise, I think this is fine.

#2 [ruby-core:81567] Updated by ioquatix (Samuel Williams) 3 months ago

I think this is a great idea. It avoids a ton of string issues - e.g. concatenating strings in Ruby before writing them out. It would be great if #write could take an array, and if possible, call writev.

#4 Updated by Glass_saga (Masaki Matsushita) about 2 months ago

  • Target version changed from 2.2.0 to 2.5

#5 [ruby-core:82020] Updated by Glass_saga (Masaki Matsushita) about 1 month ago

It would be great if #write could take an array, and if possible, call writev.

That's would be nice.

File.open("test", "w") do |f|
  f.write("foo", "bar", "baz") # use writev(2) if possible
end

Also available in: Atom PDF