event 0.2.1 → 0.4.1

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.
@@ -25,3 +25,4 @@
25
25
  #define EVENT_BACKEND_URING
26
26
 
27
27
  void Init_Event_Backend_URing(VALUE Event_Backend);
28
+ VALUE Event_Backend_URing_select(VALUE self, VALUE duration);
data/ext/event/epoll.o ADDED
Binary file
data/ext/event/event.o ADDED
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_LIBURING_H 1
4
+ #define HAVE_SYS_EPOLL_H 1
5
+ #endif
data/ext/event/extconf.rb CHANGED
@@ -28,6 +28,8 @@ extension_name = 'event'
28
28
  # The destination
29
29
  dir_config(extension_name)
30
30
 
31
+ $CFLAGS << " -Wall"
32
+
31
33
  $srcs = ["event.c"]
32
34
  $VPATH << "$(srcdir)/backend"
33
35
 
@@ -0,0 +1,84 @@
1
+ have_library: checking for -luring... -------------------- yes
2
+
3
+ "gcc -o conftest -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-linux -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wall conftest.c -L. -L/home/samuel/.rubies/ruby-3.0.1/lib -Wl,-rpath,/home/samuel/.rubies/ruby-3.0.1/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/samuel/.rubies/ruby-3.0.1/lib -L/home/samuel/.rubies/ruby-3.0.1/lib -lruby-static -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm -lm -lc"
4
+ checked program was:
5
+ /* begin */
6
+ 1: #include "ruby.h"
7
+ 2:
8
+ 3: int main(int argc, char **argv)
9
+ 4: {
10
+ 5: return !!argv[argc];
11
+ 6: }
12
+ /* end */
13
+
14
+ "gcc -o conftest -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-linux -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wall conftest.c -L. -L/home/samuel/.rubies/ruby-3.0.1/lib -Wl,-rpath,/home/samuel/.rubies/ruby-3.0.1/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/samuel/.rubies/ruby-3.0.1/lib -L/home/samuel/.rubies/ruby-3.0.1/lib -lruby-static -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm -luring -lm -lc"
15
+ checked program was:
16
+ /* begin */
17
+ 1: #include "ruby.h"
18
+ 2:
19
+ 3: /*top*/
20
+ 4: extern int t(void);
21
+ 5: int main(int argc, char **argv)
22
+ 6: {
23
+ 7: if (argc > 1000000) {
24
+ 8: int (* volatile tp)(void)=(int (*)(void))&t;
25
+ 9: printf("%d", (*tp)());
26
+ 10: }
27
+ 11:
28
+ 12: return !!argv[argc];
29
+ 13: }
30
+ 14:
31
+ 15: int t(void) { ; return 0; }
32
+ /* end */
33
+
34
+ --------------------
35
+
36
+ have_header: checking for liburing.h... -------------------- yes
37
+
38
+ "gcc -E -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-linux -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wall conftest.c -o conftest.i"
39
+ checked program was:
40
+ /* begin */
41
+ 1: #include "ruby.h"
42
+ 2:
43
+ 3: #include <liburing.h>
44
+ /* end */
45
+
46
+ --------------------
47
+
48
+ have_header: checking for sys/epoll.h... -------------------- yes
49
+
50
+ "gcc -E -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-linux -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wall conftest.c -o conftest.i"
51
+ checked program was:
52
+ /* begin */
53
+ 1: #include "ruby.h"
54
+ 2:
55
+ 3: #include <sys/epoll.h>
56
+ /* end */
57
+
58
+ --------------------
59
+
60
+ have_header: checking for sys/event.h... -------------------- no
61
+
62
+ "gcc -E -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/x86_64-linux -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0/ruby/backward -I/home/samuel/.rubies/ruby-3.0.1/include/ruby-3.0.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wall conftest.c -o conftest.i"
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.
67
+ checked program was:
68
+ /* begin */
69
+ 1: #include "ruby.h"
70
+ 2:
71
+ 3: #include <sys/event.h>
72
+ /* end */
73
+
74
+ --------------------
75
+
76
+ extconf.h is:
77
+ /* begin */
78
+ 1: #ifndef EXTCONF_H
79
+ 2: #define EXTCONF_H
80
+ 3: #define HAVE_LIBURING_H 1
81
+ 4: #define HAVE_SYS_EPOLL_H 1
82
+ 5: #endif
83
+ /* end */
84
+
data/ext/event/uring.o ADDED
Binary file
data/lib/event.rb CHANGED
@@ -19,7 +19,7 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require_relative 'event/version'
22
- require_relative 'event/backend/select'
22
+ require_relative 'event/backend'
23
23
 
24
24
  module Event
25
25
  # These constants are the same as those defined in IO.
@@ -0,0 +1,49 @@
1
+ # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative 'backend/select'
22
+
23
+ module Event
24
+ module Backend
25
+ def self.default(env = ENV)
26
+ if backend = env['EVENT_BACKEND']&.to_sym
27
+ if Event::Backend.const_defined?(backend)
28
+ return Event::Backend.const_get(backend)
29
+ else
30
+ warn "Could not find EVENT_BACKEND=#{backend}!"
31
+ end
32
+ end
33
+
34
+ if self.const_defined?(:URing)
35
+ return Event::Backend::URing
36
+ elsif self.const_defined?(:KQueue)
37
+ return Event::Backend::KQueue
38
+ elsif self.const_defined?(:EPoll)
39
+ return Event::Backend::EPoll
40
+ else
41
+ return Event::Backend::Select
42
+ end
43
+ end
44
+
45
+ def self.new(...)
46
+ default.new(...)
47
+ end
48
+ end
49
+ end
@@ -28,20 +28,33 @@ module Event
28
28
  @writable = {}
29
29
  end
30
30
 
31
+ def close
32
+ @loop = nil
33
+ @readable = nil
34
+ @writable = nil
35
+ end
36
+
31
37
  def io_wait(fiber, io, events)
38
+ remove_readable = remove_writable = false
39
+
32
40
  if (events & READABLE) > 0 or (events & PRIORITY) > 0
33
41
  @readable[io] = fiber
42
+ remove_readable = true
34
43
  end
35
44
 
36
45
  if (events & WRITABLE) > 0
37
46
  @writable[io] = fiber
47
+ remove_writable = true
38
48
  end
39
49
 
40
50
  @loop.transfer
51
+ ensure
52
+ @readable.delete(io) if remove_readable
53
+ @writable.delete(io) if remove_writable
41
54
  end
42
55
 
43
56
  def select(duration = nil)
44
- readable, writable, _ = IO.select(@readable.keys, @writable.keys, nil, duration)
57
+ readable, writable, _ = ::IO.select(@readable.keys, @writable.keys, nil, duration)
45
58
 
46
59
  ready = Hash.new(0)
47
60
 
@@ -31,6 +31,15 @@ module Event
31
31
  @priority = {}
32
32
  end
33
33
 
34
+ def close
35
+ if @selector.nil?
36
+ raise "Selector already closed!"
37
+ end
38
+
39
+ @selector.close
40
+ @selector = nil
41
+ end
42
+
34
43
  def io_wait(fiber, io, events)
35
44
  register_readable(fiber, io, events)
36
45
  end
data/lib/event/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Event
2
- VERSION = "0.2.1"
2
+ VERSION = "0.4.1"
3
3
  end
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.2.1
4
+ version: 0.4.1
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-04-27 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bake
@@ -73,6 +73,7 @@ extensions:
73
73
  - ext/event/extconf.rb
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ext/event/Makefile
76
77
  - ext/event/backend/backend.h
77
78
  - ext/event/backend/epoll.c
78
79
  - ext/event/backend/epoll.h
@@ -80,10 +81,17 @@ files:
80
81
  - ext/event/backend/kqueue.h
81
82
  - ext/event/backend/uring.c
82
83
  - ext/event/backend/uring.h
84
+ - ext/event/epoll.o
83
85
  - ext/event/event.c
84
86
  - ext/event/event.h
87
+ - ext/event/event.o
88
+ - ext/event/event.so
89
+ - ext/event/extconf.h
85
90
  - ext/event/extconf.rb
91
+ - ext/event/mkmf.log
92
+ - ext/event/uring.o
86
93
  - lib/event.rb
94
+ - lib/event/backend.rb
87
95
  - lib/event/backend/select.rb
88
96
  - lib/event/debug/selector.rb
89
97
  - lib/event/selector.rb
@@ -107,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
115
  - !ruby/object:Gem::Version
108
116
  version: '0'
109
117
  requirements: []
110
- rubygems_version: 3.1.2
118
+ rubygems_version: 3.3.0.dev
111
119
  signing_key:
112
120
  specification_version: 4
113
121
  summary: An event loop.