io-event 1.6.4 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/extconf.rb +16 -12
- data/ext/io/event/selector/selector.c +7 -0
- data/lib/io/event/debug/selector.rb +3 -3
- data/lib/io/event/interrupt.rb +2 -2
- data/lib/io/event/selector/nonblock.rb +2 -2
- data/lib/io/event/selector/select.rb +8 -6
- data/lib/io/event/selector.rb +5 -5
- data/lib/io/event/support.rb +11 -2
- data/lib/io/event/timers.rb +1 -1
- data/lib/io/event/version.rb +1 -1
- data/lib/io/event.rb +5 -5
- data/license.md +1 -0
- data/readme.md +3 -3
- data.tar.gz.sig +0 -0
- metadata +7 -4
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 853f198e7ea15ab8efd9f3c864a224af60e1c45342a226ce2768eb554b1a21bb
|
4
|
+
data.tar.gz: 8fd1da4d954a4c78072f78499b322d87fd354e22786b3858f909c91346e5f92e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ea52c93eabc794db7abb8a91eb8b7311dd81eaf0bc725d67a3a553e8591df108b71a49ca3947aa3ed4a69d5e7f0247e1ffd24e0a93c54fbd2f90fc09688c13
|
7
|
+
data.tar.gz: 69937d7849c3c3ea9fd1b657dc5184f1921a44d7f51d8184ded13112ab57a5511bebbf2e40c5acd9b06e393c8e43041a3f0feedb2c4eb70230f330a280ffe125
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/extconf.rb
CHANGED
@@ -2,46 +2,50 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
# Released under the MIT License.
|
5
|
-
# Copyright, 2021-
|
5
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
6
6
|
# Copyright, 2023, by Math Ieu.
|
7
7
|
|
8
8
|
return if RUBY_DESCRIPTION =~ /jruby/
|
9
9
|
|
10
|
-
require
|
10
|
+
require "mkmf"
|
11
11
|
|
12
12
|
gem_name = File.basename(__dir__)
|
13
|
-
extension_name =
|
13
|
+
extension_name = "IO_Event"
|
14
14
|
|
15
15
|
# dir_config(extension_name)
|
16
16
|
|
17
17
|
$CFLAGS << " -Wall -Wno-unknown-pragmas -std=c99"
|
18
18
|
|
19
|
-
if ENV.key?(
|
19
|
+
if ENV.key?("RUBY_DEBUG")
|
20
20
|
$CFLAGS << " -DRUBY_DEBUG -O0"
|
21
|
+
|
22
|
+
# Add address and undefined behaviour sanitizers:
|
23
|
+
$CFLAGS << " -fsanitize=undefined -fno-omit-frame-pointer"
|
24
|
+
$LDFLAGS << " -fsanitize=undefined"
|
21
25
|
end
|
22
26
|
|
23
27
|
$srcs = ["io/event/event.c", "io/event/selector/selector.c"]
|
24
28
|
$VPATH << "$(srcdir)/io/event"
|
25
29
|
$VPATH << "$(srcdir)/io/event/selector"
|
26
30
|
|
27
|
-
have_func(
|
28
|
-
have_func(
|
31
|
+
have_func("rb_ext_ractor_safe")
|
32
|
+
have_func("&rb_fiber_transfer")
|
29
33
|
|
30
|
-
if have_library(
|
34
|
+
if have_library("uring") and have_header("liburing.h")
|
31
35
|
$srcs << "io/event/selector/uring.c"
|
32
36
|
end
|
33
37
|
|
34
|
-
if have_header(
|
38
|
+
if have_header("sys/epoll.h")
|
35
39
|
$srcs << "io/event/selector/epoll.c"
|
36
40
|
end
|
37
41
|
|
38
|
-
if have_header(
|
42
|
+
if have_header("sys/event.h")
|
39
43
|
$srcs << "io/event/selector/kqueue.c"
|
40
44
|
end
|
41
45
|
|
42
|
-
have_header(
|
46
|
+
have_header("sys/wait.h")
|
43
47
|
|
44
|
-
have_header(
|
48
|
+
have_header("sys/eventfd.h")
|
45
49
|
$srcs << "io/event/interrupt.c"
|
46
50
|
|
47
51
|
have_func("rb_io_descriptor")
|
@@ -50,7 +54,7 @@ have_func("rb_fiber_current")
|
|
50
54
|
have_func("&rb_fiber_raise")
|
51
55
|
have_func("epoll_pwait2")
|
52
56
|
|
53
|
-
have_header(
|
57
|
+
have_header("ruby/io/buffer.h")
|
54
58
|
|
55
59
|
create_header
|
56
60
|
|
@@ -180,9 +180,15 @@ static void queue_pop(struct IO_Event_Selector *backend, struct IO_Event_Selecto
|
|
180
180
|
} else {
|
181
181
|
backend->ready = waiting->head;
|
182
182
|
}
|
183
|
+
|
184
|
+
waiting->head = NULL;
|
185
|
+
waiting->tail = NULL;
|
183
186
|
}
|
184
187
|
|
185
188
|
static void queue_push(struct IO_Event_Selector *backend, struct IO_Event_Selector_Queue *waiting) {
|
189
|
+
assert(waiting->head == NULL);
|
190
|
+
assert(waiting->tail == NULL);
|
191
|
+
|
186
192
|
if (backend->waiting) {
|
187
193
|
backend->waiting->head = waiting;
|
188
194
|
waiting->tail = backend->waiting;
|
@@ -283,6 +289,7 @@ static inline
|
|
283
289
|
void IO_Event_Selector_queue_pop(struct IO_Event_Selector *backend, struct IO_Event_Selector_Queue *ready)
|
284
290
|
{
|
285
291
|
if (DEBUG) fprintf(stderr, "IO_Event_Selector_queue_pop -> %p\n", (void*)ready->fiber);
|
292
|
+
|
286
293
|
if (ready->flags & IO_EVENT_SELECTOR_QUEUE_FIBER) {
|
287
294
|
IO_Event_Selector_fiber_transfer(ready->fiber, 0, NULL);
|
288
295
|
} else {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative "../support"
|
7
7
|
|
8
8
|
module IO::Event
|
9
9
|
module Debug
|
@@ -12,8 +12,8 @@ module IO::Event
|
|
12
12
|
def self.wrap(selector, env = ENV)
|
13
13
|
log = nil
|
14
14
|
|
15
|
-
if log_path = env[
|
16
|
-
log = File.open(log_path,
|
15
|
+
if log_path = env["IO_EVENT_DEBUG_SELECTOR_LOG"]
|
16
|
+
log = File.open(log_path, "w")
|
17
17
|
end
|
18
18
|
|
19
19
|
return self.new(selector, log: log)
|
data/lib/io/event/interrupt.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2021-
|
4
|
+
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
module IO::Event
|
7
7
|
# A thread safe synchronisation primative.
|
@@ -27,7 +27,7 @@ module IO::Event
|
|
27
27
|
|
28
28
|
# Send a sigle byte interrupt.
|
29
29
|
def signal
|
30
|
-
@output.write(
|
30
|
+
@output.write(".")
|
31
31
|
@output.flush
|
32
32
|
rescue IOError
|
33
33
|
# Ignore.
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2023, by Math Ieu.
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require_relative
|
7
|
+
require_relative "../interrupt"
|
8
|
+
require_relative "../support"
|
9
9
|
|
10
10
|
module IO::Event
|
11
11
|
module Selector
|
@@ -168,6 +168,8 @@ module IO::Event
|
|
168
168
|
if Support.fiber_scheduler_v3?
|
169
169
|
# Ruby 3.3+, full IO::Buffer support.
|
170
170
|
|
171
|
+
# Read from the given IO to the buffer.
|
172
|
+
#
|
171
173
|
# @parameter length [Integer] The minimum number of bytes to read.
|
172
174
|
# @parameter offset [Integer] The offset into the buffer to read to.
|
173
175
|
def io_read(fiber, io, buffer, length, offset = 0)
|
@@ -196,6 +198,8 @@ module IO::Event
|
|
196
198
|
return total
|
197
199
|
end
|
198
200
|
|
201
|
+
# Write to the given IO from the buffer.
|
202
|
+
#
|
199
203
|
# @parameter length [Integer] The minimum number of bytes to write.
|
200
204
|
# @parameter offset [Integer] The offset into the buffer to write from.
|
201
205
|
def io_write(fiber, io, buffer, length, offset = 0)
|
@@ -420,10 +424,8 @@ module IO::Event
|
|
420
424
|
duration = 0 unless @ready.empty?
|
421
425
|
error = nil
|
422
426
|
|
423
|
-
if duration
|
424
|
-
|
425
|
-
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
426
|
-
end
|
427
|
+
if duration&.>(0)
|
428
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
427
429
|
else
|
428
430
|
@idle_duration = 0.0
|
429
431
|
end
|
data/lib/io/event/selector.rb
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
6
|
+
require_relative "selector/select"
|
7
|
+
require_relative "debug/selector"
|
8
|
+
require_relative "support"
|
9
9
|
|
10
10
|
module IO::Event
|
11
11
|
module Selector
|
12
12
|
def self.default(env = ENV)
|
13
|
-
if name = env[
|
13
|
+
if name = env["IO_EVENT_SELECTOR"]&.to_sym
|
14
14
|
return const_get(name)
|
15
15
|
end
|
16
16
|
|
@@ -28,7 +28,7 @@ module IO::Event
|
|
28
28
|
def self.new(loop, env = ENV)
|
29
29
|
selector = default(env).new(loop)
|
30
30
|
|
31
|
-
if debug = env[
|
31
|
+
if debug = env["IO_EVENT_DEBUG_SELECTOR"]
|
32
32
|
selector = Debug::Selector.wrap(selector, env)
|
33
33
|
end
|
34
34
|
|
data/lib/io/event/support.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2022-
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
class IO
|
7
7
|
module Event
|
@@ -10,14 +10,23 @@ class IO
|
|
10
10
|
IO.const_defined?(:Buffer)
|
11
11
|
end
|
12
12
|
|
13
|
+
# To be removed on 31 Mar 2025.
|
13
14
|
def self.fiber_scheduler_v1?
|
14
|
-
IO.const_defined?(:Buffer)
|
15
|
+
IO.const_defined?(:Buffer)
|
15
16
|
end
|
16
17
|
|
18
|
+
# To be removed on 31 Mar 2026.
|
17
19
|
def self.fiber_scheduler_v2?
|
20
|
+
# Some interface changes were back-ported incorrectly:
|
21
|
+
# https://github.com/ruby/ruby/pull/10778
|
22
|
+
# Specifically "Improvements to IO::Buffer read/write/pread/pwrite."
|
23
|
+
# Missing correct size calculation.
|
24
|
+
return false if RUBY_VERSION >= "3.2.5"
|
25
|
+
|
18
26
|
IO.const_defined?(:Buffer) and Fiber.respond_to?(:blocking) and IO::Buffer.instance_method(:read).arity == -1
|
19
27
|
end
|
20
28
|
|
29
|
+
# To become the default 31 Mar 2026.
|
21
30
|
def self.fiber_scheduler_v3?
|
22
31
|
if fiber_scheduler_v2?
|
23
32
|
return true if RUBY_VERSION >= "3.3"
|
data/lib/io/event/timers.rb
CHANGED
data/lib/io/event/version.rb
CHANGED
data/lib/io/event.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
8
|
-
require_relative
|
6
|
+
require_relative "event/version"
|
7
|
+
require_relative "event/selector"
|
8
|
+
require_relative "event/timers"
|
9
9
|
|
10
10
|
begin
|
11
|
-
require
|
11
|
+
require "IO_Event"
|
12
12
|
rescue LoadError => error
|
13
13
|
warn "Could not load native event selector: #{error}"
|
14
|
-
require_relative
|
14
|
+
require_relative "event/selector/nonblock"
|
15
15
|
end
|
data/license.md
CHANGED
@@ -8,6 +8,7 @@ Copyright, 2022, by Alex Matchneer.
|
|
8
8
|
Copyright, 2022, by Bruno Sutic.
|
9
9
|
Copyright, 2023, by Math Ieu.
|
10
10
|
Copyright, 2024, by Pavel Rosický.
|
11
|
+
Copyright, 2024, by Anthony Ross.
|
11
12
|
|
12
13
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
14
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -24,8 +24,8 @@ We welcome contributions to this project.
|
|
24
24
|
|
25
25
|
### Developer Certificate of Origin
|
26
26
|
|
27
|
-
|
27
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
28
28
|
|
29
|
-
###
|
29
|
+
### Community Guidelines
|
30
30
|
|
31
|
-
This project is
|
31
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -10,6 +10,7 @@ authors:
|
|
10
10
|
- Benoit Daloze
|
11
11
|
- Bruno Sutic
|
12
12
|
- Alex Matchneer
|
13
|
+
- Anthony Ross
|
13
14
|
- Delton Ding
|
14
15
|
- Pavel Rosický
|
15
16
|
autorequire:
|
@@ -44,7 +45,7 @@ cert_chain:
|
|
44
45
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
45
46
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
46
47
|
-----END CERTIFICATE-----
|
47
|
-
date: 2024-
|
48
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
48
49
|
dependencies: []
|
49
50
|
description:
|
50
51
|
email:
|
@@ -85,7 +86,9 @@ files:
|
|
85
86
|
homepage: https://github.com/socketry/io-event
|
86
87
|
licenses:
|
87
88
|
- MIT
|
88
|
-
metadata:
|
89
|
+
metadata:
|
90
|
+
documentation_uri: https://socketry.github.io/io-event/
|
91
|
+
source_code_uri: https://github.com/socketry/io-event.git
|
89
92
|
post_install_message:
|
90
93
|
rdoc_options: []
|
91
94
|
require_paths:
|
@@ -101,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
104
|
- !ruby/object:Gem::Version
|
102
105
|
version: '0'
|
103
106
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.4.19
|
105
108
|
signing_key:
|
106
109
|
specification_version: 4
|
107
110
|
summary: An event loop.
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
\�nKY�0�j�_sx���}�u�� �G9�u��媷F�S����S�&Ni&UTt�kUXV<Ŏ�ZS�s�C�����A�k`8z���hB@�DS�������aqX��q�ը��ƕNLS�wrcR9i�0�_�OE{y�h��=3]-b8ł�~�&����Y��
|
2
|
+
�9o�>��?��d]m�"2�w�8�h)�tu��Q�C���ϯ��j�L��1���(q�@J(8���Rʬ��Lk?�K��*D��y3�/<���#&�A�!{a��b��(z¤��xi6#v��Z���L�b�Z�s����L0�����o�������h�/���6q\z^�K���$��c��앓ssΏ%�wS;�Pҫ-Q|\@
|