io-poll 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/io/poll.rb +11 -11
- metadata +37 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00fa31630277609bf6ad35701aa21f1129424789
|
4
|
+
data.tar.gz: 30c6e4b5702c949b7aec34e979a8d6afb2433340
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 927bd7d7024b32f0746a873fdc05b3bc726c683cfb81f213c3093295cca569585926826d09bd9a8421a52d5af9b1ae6bc7d0cf9b0624a96d290bf74684eda07b
|
7
|
+
data.tar.gz: 2438133c2ba8903601e1544d7d755d2d76d66571ec4ceaca39351c6345f612925f5818faa0fbb8d45bcf518e11438e7f99759a7a7451712e3db6a9b62c76635c
|
data/README.md
CHANGED
@@ -8,12 +8,14 @@ Ruby 1.8's IO.select() smashes the stack when given >1024 fds, and Ruby doesn't
|
|
8
8
|
Usage
|
9
9
|
-----
|
10
10
|
|
11
|
+
```ruby
|
11
12
|
require 'io/poll'
|
12
13
|
read_fds = [STDIN]
|
13
14
|
write_fds = [STDOUT]
|
14
15
|
err_fds = []
|
15
16
|
poll_period = 60
|
16
17
|
read_fds, write_fds, err_fds = IO.select_using_poll(read_fds, write_fds, err_fds, poll_period)
|
18
|
+
```
|
17
19
|
|
18
20
|
|
19
21
|
BUGS/TODO
|
data/lib/io/poll.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
class IO
|
4
4
|
module Poll
|
5
5
|
arch, os = RUBY_PLATFORM.split('-')
|
6
|
-
if os =~ /^darwin/
|
6
|
+
if os =~ /^darwin|^freebsd/
|
7
7
|
# /usr/include/sys/poll.h
|
8
8
|
# Requestable events. If poll(2) finds any of these set, they are
|
9
9
|
# copied to revents on return.
|
@@ -25,9 +25,9 @@ class IO
|
|
25
25
|
POLLERR = 0x0008 #/* some poll error occurred */
|
26
26
|
POLLHUP = 0x0010 #/* file descriptor was "hung up" */
|
27
27
|
POLLNVAL = 0x0020 #/* requested events "invalid" */
|
28
|
-
|
28
|
+
|
29
29
|
POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
|
30
|
-
|
30
|
+
|
31
31
|
elsif os == "linux"
|
32
32
|
# /usr/include/bits/poll.h
|
33
33
|
#/* Event types that can be polled for. These bits may be set in `events'
|
@@ -36,28 +36,28 @@ class IO
|
|
36
36
|
POLLIN = 0x001 #/* There is data to read. */
|
37
37
|
POLLPRI = 0x002 #/* There is urgent data to read. */
|
38
38
|
POLLOUT = 0x004 #/* Writing now will not block. */
|
39
|
-
|
39
|
+
|
40
40
|
#/* These values are defined in XPG4.2. */
|
41
41
|
POLLRDNORM = 0x040 #/* Normal data may be read. */
|
42
42
|
POLLRDBAND = 0x080 #/* Priority data may be read. */
|
43
43
|
POLLWRNORM = 0x100 #/* Writing now will not block. */
|
44
44
|
POLLWRBAND = 0x200 #/* Priority data may be written. */
|
45
|
-
|
45
|
+
|
46
46
|
#/* These are extensions for Linux. */
|
47
47
|
POLLMSG = 0x400
|
48
48
|
POLLREMOVE = 0x1000
|
49
49
|
POLLRDHUP = 0x2000
|
50
|
-
|
50
|
+
|
51
51
|
#/* Event types always implicitly polled for. These bits need not be set in
|
52
52
|
# `events', but they will appear in `revents' to indicate the status of
|
53
53
|
# the file descriptor. */
|
54
54
|
POLLERR = 0x008 # /* Error condition. */
|
55
55
|
POLLHUP = 0x010 # /* Hung up. */
|
56
56
|
POLLNVAL = 0x020 # /* Invalid polling request. */
|
57
|
-
|
57
|
+
|
58
58
|
# not part of poll.h on linux, but looks handy
|
59
59
|
POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
|
60
|
-
|
60
|
+
|
61
61
|
else
|
62
62
|
raise "unknown platform: #{RUBY_PLATFORM}"
|
63
63
|
end
|
@@ -141,18 +141,18 @@ if __FILE__ == $0
|
|
141
141
|
struct[:events] = IO::Poll::POLLSTANDARD
|
142
142
|
struct[:revents] = 0
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
# call poll
|
146
146
|
# The resulting pollfds structure will have :revents populated with the poll results
|
147
147
|
# The pollfds structure can be re-used
|
148
148
|
ret = IO.poll(pollfds, pollfd_len, 4);
|
149
149
|
|
150
150
|
STDERR.puts "ret: #{ret.inspect}"
|
151
|
-
|
151
|
+
|
152
152
|
# Implement IO.select() using poll(). Easy to use, terrible performance.
|
153
153
|
using_poll = IO.select_using_poll([STDIN], [STDOUT], [], 5);
|
154
154
|
using_kern_select = IO.select([STDIN], [STDOUT], [], 5);
|
155
|
-
|
155
|
+
|
156
156
|
STDERR.puts "IO.select_using_poll([#{STDIN.inspect}], [#{STDOUT.inspect}], [], 5):"
|
157
157
|
STDERR.puts using_poll.inspect
|
158
158
|
STDERR.puts "and inval is: #{IO::Poll::POLLNVAL}"
|
metadata
CHANGED
@@ -1,83 +1,63 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-poll
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Evan Miller
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: ffi
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
32
20
|
type: :runtime
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Ruby 1.8's IO.select() smashes the stack when given >1024 fds, and Ruby
|
28
|
+
doesn't implement IO.poll().
|
29
|
+
email:
|
36
30
|
- github@squareup.com
|
37
31
|
executables: []
|
38
|
-
|
39
32
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
33
|
+
extra_rdoc_files:
|
42
34
|
- LICENSE.md
|
43
|
-
files:
|
35
|
+
files:
|
44
36
|
- lib/io/poll.rb
|
45
37
|
- README.md
|
46
38
|
- LICENSE.md
|
47
39
|
homepage: http://github.com/square/prodeng
|
48
40
|
licenses: []
|
49
|
-
|
41
|
+
metadata: {}
|
50
42
|
post_install_message:
|
51
|
-
rdoc_options:
|
43
|
+
rdoc_options:
|
52
44
|
- --charset=UTF-8
|
53
|
-
require_paths:
|
45
|
+
require_paths:
|
54
46
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
hash: 23
|
70
|
-
segments:
|
71
|
-
- 1
|
72
|
-
- 3
|
73
|
-
- 6
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
74
56
|
version: 1.3.6
|
75
57
|
requirements: []
|
76
|
-
|
77
58
|
rubyforge_project:
|
78
|
-
rubygems_version:
|
59
|
+
rubygems_version: 2.0.14.1
|
79
60
|
signing_key:
|
80
|
-
specification_version:
|
61
|
+
specification_version: 4
|
81
62
|
summary: FFI bindings for poll(2) and select(2) emulation
|
82
63
|
test_files: []
|
83
|
-
|