event 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/event/Makefile +28 -27
- data/ext/event/backend.o +0 -0
- data/ext/event/backend/backend.c +108 -0
- data/ext/event/backend/backend.h +17 -1
- data/ext/event/backend/epoll.c +215 -7
- data/ext/event/backend/kqueue.c +244 -11
- data/ext/event/backend/pidfd.c +36 -0
- data/ext/event/backend/uring.c +181 -104
- data/ext/event/event.bundle +0 -0
- data/ext/event/event.c +3 -0
- data/ext/event/event.h +3 -3
- data/ext/event/event.o +0 -0
- data/ext/event/extconf.h +1 -2
- data/ext/event/extconf.rb +3 -1
- data/ext/event/kqueue.o +0 -0
- data/ext/event/mkmf.log +37 -21
- data/lib/event/backend/select.rb +62 -1
- data/lib/event/version.rb +1 -1
- metadata +8 -6
- data/ext/event/epoll.o +0 -0
- data/ext/event/event.so +0 -0
- data/ext/event/uring.o +0 -0
Binary file
|
data/ext/event/event.c
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
// THE SOFTWARE.
|
20
20
|
|
21
21
|
#include "event.h"
|
22
|
+
#include "backend/backend.h"
|
22
23
|
|
23
24
|
VALUE Event = Qnil;
|
24
25
|
VALUE Event_Backend = Qnil;
|
@@ -32,6 +33,8 @@ void Init_event()
|
|
32
33
|
Event = rb_define_module("Event");
|
33
34
|
Event_Backend = rb_define_module_under(Event, "Backend");
|
34
35
|
|
36
|
+
Init_Event_Backend(Event_Backend);
|
37
|
+
|
35
38
|
#ifdef EVENT_BACKEND_URING
|
36
39
|
Init_Event_Backend_URing(Event_Backend);
|
37
40
|
#endif
|
data/ext/event/event.h
CHANGED
@@ -26,14 +26,14 @@
|
|
26
26
|
|
27
27
|
void Init_event();
|
28
28
|
|
29
|
-
#
|
29
|
+
#ifdef HAVE_LIBURING_H
|
30
30
|
#include "backend/uring.h"
|
31
31
|
#endif
|
32
32
|
|
33
|
-
#
|
33
|
+
#ifdef HAVE_SYS_EPOLL_H
|
34
34
|
#include "backend/epoll.h"
|
35
35
|
#endif
|
36
36
|
|
37
|
-
#
|
37
|
+
#ifdef HAVE_SYS_EVENT_H
|
38
38
|
#include "backend/kqueue.h"
|
39
39
|
#endif
|
data/ext/event/event.o
CHANGED
Binary file
|
data/ext/event/extconf.h
CHANGED
data/ext/event/extconf.rb
CHANGED
@@ -30,9 +30,11 @@ dir_config(extension_name)
|
|
30
30
|
|
31
31
|
$CFLAGS << " -Wall"
|
32
32
|
|
33
|
-
$srcs = ["event.c"]
|
33
|
+
$srcs = ["event.c", "backend/backend.c"]
|
34
34
|
$VPATH << "$(srcdir)/backend"
|
35
35
|
|
36
|
+
have_func('&rb_fiber_transfer')
|
37
|
+
|
36
38
|
if have_library('uring') and have_header('liburing.h')
|
37
39
|
$srcs << "backend/uring.c"
|
38
40
|
end
|
data/ext/event/kqueue.o
ADDED
Binary file
|
data/ext/event/mkmf.log
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
have_func: checking for &rb_fiber_transfer()... -------------------- no
|
2
2
|
|
3
|
-
"
|
3
|
+
"clang -fdeclspec -o conftest -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-darwin20 -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe -Wall conftest.c -L. -L/Users/samuel/.rubies/ruby-3.0.1/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -lruby.3.0-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc "
|
4
4
|
checked program was:
|
5
5
|
/* begin */
|
6
6
|
1: #include "ruby.h"
|
@@ -11,7 +11,11 @@ checked program was:
|
|
11
11
|
6: }
|
12
12
|
/* end */
|
13
13
|
|
14
|
-
"
|
14
|
+
"clang -fdeclspec -o conftest -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-darwin20 -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe -Wall conftest.c -L. -L/Users/samuel/.rubies/ruby-3.0.1/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -lruby.3.0-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc "
|
15
|
+
conftest.c:14:76: error: use of undeclared identifier 'rb_fiber_transfer'
|
16
|
+
int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_fiber_transfer; return !p; }
|
17
|
+
^
|
18
|
+
1 error generated.
|
15
19
|
checked program was:
|
16
20
|
/* begin */
|
17
21
|
1: #include "ruby.h"
|
@@ -27,27 +31,44 @@ checked program was:
|
|
27
31
|
11:
|
28
32
|
12: return !!argv[argc];
|
29
33
|
13: }
|
30
|
-
14:
|
31
|
-
15: int t(void) { ; return 0; }
|
34
|
+
14: int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_fiber_transfer; return !p; }
|
32
35
|
/* end */
|
33
36
|
|
34
37
|
--------------------
|
35
38
|
|
36
|
-
|
39
|
+
have_library: checking for -luring... -------------------- no
|
37
40
|
|
38
|
-
"
|
41
|
+
"clang -fdeclspec -o conftest -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-darwin20 -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe -Wall conftest.c -L. -L/Users/samuel/.rubies/ruby-3.0.1/lib -L/opt/local/lib -L. -fstack-protector-strong -L/opt/local/lib -lruby.3.0-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc -luring "
|
42
|
+
ld: library not found for -luring
|
43
|
+
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
39
44
|
checked program was:
|
40
45
|
/* begin */
|
41
|
-
1: #include "ruby.h"
|
42
|
-
2:
|
43
|
-
3:
|
46
|
+
1: #include "ruby.h"
|
47
|
+
2:
|
48
|
+
3: /*top*/
|
49
|
+
4: extern int t(void);
|
50
|
+
5: int main(int argc, char **argv)
|
51
|
+
6: {
|
52
|
+
7: if (argc > 1000000) {
|
53
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
54
|
+
9: printf("%d", (*tp)());
|
55
|
+
10: }
|
56
|
+
11:
|
57
|
+
12: return !!argv[argc];
|
58
|
+
13: }
|
59
|
+
14:
|
60
|
+
15: int t(void) { ; return 0; }
|
44
61
|
/* end */
|
45
62
|
|
46
63
|
--------------------
|
47
64
|
|
48
|
-
have_header: checking for sys/epoll.h... --------------------
|
65
|
+
have_header: checking for sys/epoll.h... -------------------- no
|
49
66
|
|
50
|
-
"
|
67
|
+
"clang -E -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-darwin20 -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe -Wall conftest.c -o conftest.i"
|
68
|
+
conftest.c:3:10: fatal error: 'sys/epoll.h' file not found
|
69
|
+
#include <sys/epoll.h>
|
70
|
+
^~~~~~~~~~~~~
|
71
|
+
1 error generated.
|
51
72
|
checked program was:
|
52
73
|
/* begin */
|
53
74
|
1: #include "ruby.h"
|
@@ -57,13 +78,9 @@ checked program was:
|
|
57
78
|
|
58
79
|
--------------------
|
59
80
|
|
60
|
-
have_header: checking for sys/event.h... --------------------
|
81
|
+
have_header: checking for sys/event.h... -------------------- yes
|
61
82
|
|
62
|
-
"
|
63
|
-
conftest.c:3:10: fatal error: sys/event.h: No such file or directory
|
64
|
-
3 | #include <sys/event.h>
|
65
|
-
| ^~~~~~~~~~~~~
|
66
|
-
compilation terminated.
|
83
|
+
"clang -E -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-darwin20 -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/Users/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -pipe -Wall conftest.c -o conftest.i"
|
67
84
|
checked program was:
|
68
85
|
/* begin */
|
69
86
|
1: #include "ruby.h"
|
@@ -77,8 +94,7 @@ extconf.h is:
|
|
77
94
|
/* begin */
|
78
95
|
1: #ifndef EXTCONF_H
|
79
96
|
2: #define EXTCONF_H
|
80
|
-
3: #define
|
81
|
-
4: #
|
82
|
-
5: #endif
|
97
|
+
3: #define HAVE_SYS_EVENT_H 1
|
98
|
+
4: #endif
|
83
99
|
/* end */
|
84
100
|
|
data/lib/event/backend/select.rb
CHANGED
@@ -53,6 +53,67 @@ module Event
|
|
53
53
|
@writable.delete(io) if remove_writable
|
54
54
|
end
|
55
55
|
|
56
|
+
def io_read(fiber, io, buffer, offset, length)
|
57
|
+
buffer.force_encoding(Encoding::BINARY)
|
58
|
+
|
59
|
+
while length > 0
|
60
|
+
case result = io.read_nonblock(length, exception: false)
|
61
|
+
when :wait_readable
|
62
|
+
self.io_wait(fiber, io, READABLE)
|
63
|
+
when :wait_writable
|
64
|
+
self.io_wait(fiber, io, WRITABLE)
|
65
|
+
else
|
66
|
+
result.force_encoding(Encoding::BINARY)
|
67
|
+
buffer[offset, result.bytesize] = result
|
68
|
+
|
69
|
+
offset += result.bytesize
|
70
|
+
length -= result.bytesize
|
71
|
+
end
|
72
|
+
end
|
73
|
+
rescue EOFError
|
74
|
+
return nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def io_write(fiber, io, buffer, offset, length)
|
78
|
+
buffer.force_encoding(Encoding::BINARY)
|
79
|
+
|
80
|
+
total = 0
|
81
|
+
|
82
|
+
while length > 0
|
83
|
+
chunk = buffer[offset, length]
|
84
|
+
case result = io.write_nonblock(chunk, exception: false)
|
85
|
+
when :wait_readable
|
86
|
+
self.io_wait(fiber, io, READABLE)
|
87
|
+
when :wait_writable
|
88
|
+
self.io_wait(fiber, io, WRITABLE)
|
89
|
+
else
|
90
|
+
offset += result
|
91
|
+
length -= result
|
92
|
+
total += result
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
return total
|
97
|
+
end
|
98
|
+
|
99
|
+
def process_wait(fiber, pid, flags)
|
100
|
+
r, w = IO.pipe
|
101
|
+
|
102
|
+
thread = Thread.new do
|
103
|
+
Process::Status.wait(pid, flags)
|
104
|
+
ensure
|
105
|
+
w.close
|
106
|
+
end
|
107
|
+
|
108
|
+
self.io_wait(fiber, r, READABLE)
|
109
|
+
|
110
|
+
return thread.value
|
111
|
+
ensure
|
112
|
+
r.close
|
113
|
+
w.close
|
114
|
+
thread&.kill
|
115
|
+
end
|
116
|
+
|
56
117
|
def select(duration = nil)
|
57
118
|
readable, writable, _ = ::IO.select(@readable.keys, @writable.keys, nil, duration)
|
58
119
|
|
@@ -69,7 +130,7 @@ module Event
|
|
69
130
|
end
|
70
131
|
|
71
132
|
ready.each do |fiber, events|
|
72
|
-
fiber.transfer(events)
|
133
|
+
fiber.transfer(events) if fiber.alive?
|
73
134
|
end
|
74
135
|
end
|
75
136
|
end
|
data/lib/event/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bake
|
@@ -74,22 +74,24 @@ extensions:
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ext/event/Makefile
|
77
|
+
- ext/event/backend.o
|
78
|
+
- ext/event/backend/backend.c
|
77
79
|
- ext/event/backend/backend.h
|
78
80
|
- ext/event/backend/epoll.c
|
79
81
|
- ext/event/backend/epoll.h
|
80
82
|
- ext/event/backend/kqueue.c
|
81
83
|
- ext/event/backend/kqueue.h
|
84
|
+
- ext/event/backend/pidfd.c
|
82
85
|
- ext/event/backend/uring.c
|
83
86
|
- ext/event/backend/uring.h
|
84
|
-
- ext/event/
|
87
|
+
- ext/event/event.bundle
|
85
88
|
- ext/event/event.c
|
86
89
|
- ext/event/event.h
|
87
90
|
- ext/event/event.o
|
88
|
-
- ext/event/event.so
|
89
91
|
- ext/event/extconf.h
|
90
92
|
- ext/event/extconf.rb
|
93
|
+
- ext/event/kqueue.o
|
91
94
|
- ext/event/mkmf.log
|
92
|
-
- ext/event/uring.o
|
93
95
|
- lib/event.rb
|
94
96
|
- lib/event/backend.rb
|
95
97
|
- lib/event/backend/select.rb
|
@@ -115,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
117
|
- !ruby/object:Gem::Version
|
116
118
|
version: '0'
|
117
119
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.2.15
|
119
121
|
signing_key:
|
120
122
|
specification_version: 4
|
121
123
|
summary: An event loop.
|
data/ext/event/epoll.o
DELETED
Binary file
|
data/ext/event/event.so
DELETED
Binary file
|
data/ext/event/uring.o
DELETED
Binary file
|