Class: IO
- Defined in:
- lib/puppet/external/event-loop/event-loop.rb,
lib/puppet/util/monkey_patches.rb
Instance Method Summary collapse
- #lines(separator = $/) ⇒ Object
- #on_exceptional(&block) ⇒ Object
- #on_readable(&block) ⇒ Object
- #on_writable(&block) ⇒ Object
- #will_block=(wants_blocking) ⇒ Object
- #will_block? ⇒ Boolean
Instance Method Details
#lines(separator = $/) ⇒ Object
127 128 129 130 131 |
# File 'lib/puppet/util/monkey_patches.rb', line 127 def lines(separator = $/) lines = split(separator) block_given? and lines.each {|line| yield line } lines end |
#on_exceptional(&block) ⇒ Object
233 234 235 236 |
# File 'lib/puppet/external/event-loop/event-loop.rb', line 233 def on_exceptional &block extend EventLoop::Watchable::Automatic on_exceptional(&block) end |
#on_readable(&block) ⇒ Object
223 224 225 226 |
# File 'lib/puppet/external/event-loop/event-loop.rb', line 223 def on_readable &block extend EventLoop::Watchable::Automatic on_readable(&block) end |
#on_writable(&block) ⇒ Object
228 229 230 231 |
# File 'lib/puppet/external/event-loop/event-loop.rb', line 228 def on_writable &block extend EventLoop::Watchable::Automatic on_writable(&block) end |
#will_block=(wants_blocking) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/puppet/external/event-loop/event-loop.rb', line 244 def will_block= (wants_blocking) if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) and defined?(Fcntl::O_NONBLOCK) flags = fcntl(Fcntl::F_GETFL, 0) if wants_blocking flags &= ~Fcntl::O_NONBLOCK else flags |= Fcntl::O_NONBLOCK end fcntl(Fcntl::F_SETFL, flags) end end |
#will_block? ⇒ Boolean
238 239 240 241 242 |
# File 'lib/puppet/external/event-loop/event-loop.rb', line 238 def will_block? if respond_to?(:fcntl) and defined?(Fcntl) and defined?(Fcntl::F_GETFL) and defined?(Fcntl::O_NONBLOCK) fcntl(Fcntl::F_GETFL, 0) & Fcntl::O_NONBLOCK == 0 end end |