source:
extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/io/nonblock.rb@
18425
Last change on this file since 18425 was 18425, checked in by , 15 years ago | |
---|---|
File size: 408 bytes |
Line | |
---|---|
1 | require "fcntl" |
2 | class IO |
3 | def nonblock? |
4 | (fcntl(Fcntl::F_GETFL) & File::NONBLOCK) != 0 |
5 | end |
6 | |
7 | def nonblock=(nb) |
8 | f = fcntl(Fcntl::F_GETFL) |
9 | if nb |
10 | f |= File::NONBLOCK |
11 | else |
12 | f &= ~File::NONBLOCK |
13 | end |
14 | fcntl(Fcntl::F_SETFL, f) |
15 | end |
16 | |
17 | def nonblock(nb = true) |
18 | nb, self.nonblock = nonblock?, nb |
19 | yield |
20 | ensure |
21 | self.nonblock = nb |
22 | end |
23 | end if defined?(Fcntl::F_GETFL) |
Note:
See TracBrowser
for help on using the repository browser.