Class: IO
- Inherits:
-
Object
- Object
- IO
- Defined in:
- wait/lib/nonblock.rb
Instance Method Summary collapse
- #nonblock(nb = true) ⇒ Object
- #nonblock=(nb) ⇒ Object
- #nonblock? ⇒ Boolean
-
#ready? ⇒ Boolean
=begin --- IO#ready? returns non-nil if input available without blocking, or nil.
-
#wait ⇒ Object
=begin --- IO#wait([timeout]) waits until input available or timed out and returns self, or nil when EOF reached.
Instance Method Details
#nonblock(nb = true) ⇒ Object
17 18 19 20 21 22 |
# File 'wait/lib/nonblock.rb', line 17 def nonblock(nb = true) nb, self.nonblock = nonblock?, nb yield ensure self.nonblock = nb end |
#nonblock=(nb) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'wait/lib/nonblock.rb', line 7 def nonblock=(nb) f = fcntl(Fcntl::F_GETFL) if nb f |= File::NONBLOCK else f &= ~File::NONBLOCK end fcntl(Fcntl::F_SETFL, f) end |
#nonblock? ⇒ Boolean
3 4 5 |
# File 'wait/lib/nonblock.rb', line 3 def nonblock? (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) != 0 end |
#ready? ⇒ Boolean
=begin --- IO#ready? returns non-nil if input available without blocking, or nil. =end
55 56 57 |
# File 'wait/wait.c', line 55 static VALUE io_ready_p(io) VALUE io; |
#wait ⇒ Object
=begin --- IO#wait([timeout]) waits until input available or timed out and returns self, or nil when EOF reached. =end
81 82 83 |
# File 'wait/wait.c', line 81 static VALUE io_wait(argc, argv, io) int argc; |