Class: IO
Instance Method Summary collapse
- #close_on_exec! ⇒ Object
-
#writev(components) ⇒ Object
Writes all of the strings in the
components
array into the given file descriptor using the writev() system call. -
#writev2(components, components2) ⇒ Object
Like #writev, but accepts two arrays.
-
#writev3(components, components2, components3) ⇒ Object
Like #writev, but accepts three arrays.
Instance Method Details
#close_on_exec! ⇒ Object
994 995 996 |
# File 'lib/phusion_passenger/utils.rb', line 994 def close_on_exec! fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end |
#writev(components) ⇒ Object
Writes all of the strings in the components
array into the given file descriptor using the writev() system call. Unlike IO#write, this method does not require one to concatenate all those strings into a single buffer in order to send the data in a single system call. Thus, #writev is a great way to perform zero-copy I/O.
Unlike the raw writev() system call, this method ensures that all given data is written before returning, by performing multiple writev() calls and whatever else is necessary.
io.writev(["hello ", "world", "\n"])
970 971 972 |
# File 'lib/phusion_passenger/utils.rb', line 970 def writev(components) return PhusionPassenger::NativeSupport.writev(fileno, components) end |
#writev2(components, components2) ⇒ Object
Like #writev, but accepts two arrays. The data is written in the given order.
io.writev2(["hello ", "world", "\n"], ["another ", "message\n"])
977 978 979 980 |
# File 'lib/phusion_passenger/utils.rb', line 977 def writev2(components, components2) return PhusionPassenger::NativeSupport.writev2(fileno, components, components2) end |
#writev3(components, components2, components3) ⇒ Object
Like #writev, but accepts three arrays. The data is written in the given order.
io.writev3(["hello ", "world", "\n"],
["another ", "message\n"],
["yet ", "another ", "one", "\n"])
987 988 989 990 |
# File 'lib/phusion_passenger/utils.rb', line 987 def writev3(components, components2, components3) return PhusionPassenger::NativeSupport.writev3(fileno, components, components2, components3) end |