1 # -*- encoding: binary -*-
2 require 'sleepy_penguin_ext'
4 # We need to serialize Inotify#take for Rubinius since that has no GVL
5 # to protect the internal array
6 if defined?(SleepyPenguin::Inotify) &&
7 defined?(Rubinius) && Rubinius.respond_to?(:synchronize)
8 class SleepyPenguin::Inotify
13 Rubinius.synchronize(@inotify_tmp) { __take(*args) }
20 require_relative 'sleepy_penguin/splice' if respond_to?(:__splice)
21 require_relative 'sleepy_penguin/cfr' if respond_to?(:__cfr)
22 require_relative 'sleepy_penguin/epoll' if const_defined?(:Epoll)
23 require_relative 'sleepy_penguin/kqueue' if const_defined?(:Kqueue)
25 # Copies +len+ bytes from +src+ to +dst+, where +src+ refers to
26 # an open, mmap(2)-able File and +dst+ refers to a Socket.
27 # An optional +offset+ keyword may be specified for the +src+ File.
28 # Using +offset+ will not adjust the offset of the underlying file
29 # handle itself; in other words: this allows concurrent threads to
30 # use linux_sendfile to write data from one open file to multiple
33 # Returns the number of bytes written on success, or :wait_writable
34 # if the +dst+ Socket is non-blocking and the operation would block.
35 # A return value of zero bytes indicates EOF is reached on the +src+
38 # Newer OSes may be more flexible in whether or not +dst+ or +src+
39 # is a regular file or socket, respectively.
41 # This method was added in sleepy_penguin 3.5.0.
42 def self.linux_sendfile(dst, src, len, offset: nil)
43 __lsf(dst, src, offset, len)