io-event 1.6.0 → 1.6.3
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/extconf.rb +2 -0
- data/ext/io/event/selector/epoll.c +8 -11
- data/ext/io/event/selector/kqueue.c +8 -11
- data/ext/io/event/selector/selector.h +3 -2
- data/ext/io/event/selector/uring.c +8 -11
- data/lib/io/event/selector/select.rb +5 -2
- data/lib/io/event/timers.rb +15 -11
- data/lib/io/event/version.rb +1 -1
- data/readme.md +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd1596a8aee7671e72fa97a26edea4613394765bb99723729228e6e6d5705cd
|
4
|
+
data.tar.gz: 42039ad9987d6e780e33091a812d9296527591cc7f187bf5c0a23fbf22d77981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49c7e7ea64f291f831e77b83fccc5ebd9cc610eb25032bd8c8d2bac5937190bcdaa68da6149831ed90b8a508b7a7ad68cf629663aa03c6f1892272db234ed3ba
|
7
|
+
data.tar.gz: 1c51c881b4746c819f0967041e3fb580ee5cc79163be5783831a5a72f16d64ad5ca592746d530ec78b77f70590ed81cdffbf34c46b4d46982d950e5ca46e1bfa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/extconf.rb
CHANGED
@@ -786,24 +786,21 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
786
786
|
return NULL;
|
787
787
|
}
|
788
788
|
|
789
|
-
if (
|
789
|
+
if (RB_INTEGER_TYPE_P(duration)) {
|
790
790
|
storage->tv_sec = NUM2TIMET(duration);
|
791
791
|
storage->tv_nsec = 0;
|
792
792
|
|
793
793
|
return storage;
|
794
794
|
}
|
795
795
|
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
return storage;
|
804
|
-
}
|
796
|
+
duration = rb_to_float(duration);
|
797
|
+
double value = RFLOAT_VALUE(duration);
|
798
|
+
time_t seconds = value;
|
799
|
+
|
800
|
+
storage->tv_sec = seconds;
|
801
|
+
storage->tv_nsec = (value - seconds) * 1000000000L;
|
805
802
|
|
806
|
-
|
803
|
+
return storage;
|
807
804
|
}
|
808
805
|
|
809
806
|
static
|
@@ -799,24 +799,21 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
799
799
|
return NULL;
|
800
800
|
}
|
801
801
|
|
802
|
-
if (
|
802
|
+
if (RB_INTEGER_TYPE_P(duration)) {
|
803
803
|
storage->tv_sec = NUM2TIMET(duration);
|
804
804
|
storage->tv_nsec = 0;
|
805
805
|
|
806
806
|
return storage;
|
807
807
|
}
|
808
808
|
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
return storage;
|
817
|
-
}
|
809
|
+
duration = rb_to_float(duration);
|
810
|
+
double value = RFLOAT_VALUE(duration);
|
811
|
+
time_t seconds = value;
|
812
|
+
|
813
|
+
storage->tv_sec = seconds;
|
814
|
+
storage->tv_nsec = (value - seconds) * 1000000000L;
|
818
815
|
|
819
|
-
|
816
|
+
return storage;
|
820
817
|
}
|
821
818
|
|
822
819
|
static
|
@@ -901,24 +901,21 @@ struct __kernel_timespec * make_timeout(VALUE duration, struct __kernel_timespec
|
|
901
901
|
return NULL;
|
902
902
|
}
|
903
903
|
|
904
|
-
if (
|
904
|
+
if (RB_INTEGER_TYPE_P(duration)) {
|
905
905
|
storage->tv_sec = NUM2TIMET(duration);
|
906
906
|
storage->tv_nsec = 0;
|
907
907
|
|
908
908
|
return storage;
|
909
909
|
}
|
910
910
|
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
return storage;
|
919
|
-
}
|
911
|
+
duration = rb_to_float(duration);
|
912
|
+
double value = RFLOAT_VALUE(duration);
|
913
|
+
time_t seconds = value;
|
914
|
+
|
915
|
+
storage->tv_sec = seconds;
|
916
|
+
storage->tv_nsec = (value - seconds) * 1000000000L;
|
920
917
|
|
921
|
-
|
918
|
+
return storage;
|
922
919
|
}
|
923
920
|
|
924
921
|
static
|
@@ -420,8 +420,11 @@ module IO::Event
|
|
420
420
|
duration = 0 unless @ready.empty?
|
421
421
|
error = nil
|
422
422
|
|
423
|
-
if duration
|
424
|
-
|
423
|
+
if duration
|
424
|
+
duration = duration/1.0
|
425
|
+
if duration > 0
|
426
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
427
|
+
end
|
425
428
|
else
|
426
429
|
@idle_duration = 0.0
|
427
430
|
end
|
data/lib/io/event/timers.rb
CHANGED
@@ -9,20 +9,20 @@ class IO
|
|
9
9
|
module Event
|
10
10
|
class Timers
|
11
11
|
class Handle
|
12
|
-
def initialize(
|
13
|
-
@
|
12
|
+
def initialize(time, block)
|
13
|
+
@time = time
|
14
14
|
@block = block
|
15
15
|
end
|
16
16
|
|
17
17
|
def < other
|
18
|
-
@
|
18
|
+
@time < other.time
|
19
19
|
end
|
20
20
|
|
21
21
|
def > other
|
22
|
-
@
|
22
|
+
@time > other.time
|
23
23
|
end
|
24
24
|
|
25
|
-
attr :
|
25
|
+
attr :time
|
26
26
|
attr :block
|
27
27
|
|
28
28
|
def call(...)
|
@@ -49,15 +49,19 @@ class IO
|
|
49
49
|
return @heap.size
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
# Schedule a block to be called at a specific time in the future.
|
53
|
+
# @parameter time [Time] The time at which the block should be called, relative to {#now}.
|
54
|
+
def schedule(time, block)
|
55
|
+
handle = Handle.new(time, block)
|
54
56
|
@scheduled << handle
|
55
57
|
|
56
58
|
return handle
|
57
59
|
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
+
# Schedule a block to be called after a specific time offset, relative to the current time as returned by {#now}.
|
62
|
+
# @parameter offset [Time] The time offset from the current time at which the block should be called.
|
63
|
+
def after(offset, &block)
|
64
|
+
schedule(self.now + offset, block)
|
61
65
|
end
|
62
66
|
|
63
67
|
def wait_interval(now = self.now)
|
@@ -67,7 +71,7 @@ class IO
|
|
67
71
|
if handle.cancelled?
|
68
72
|
@heap.pop
|
69
73
|
else
|
70
|
-
return handle.
|
74
|
+
return handle.time - now
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -84,7 +88,7 @@ class IO
|
|
84
88
|
while handle = @heap.peek
|
85
89
|
if handle.cancelled?
|
86
90
|
@heap.pop
|
87
|
-
elsif handle.
|
91
|
+
elsif handle.time <= now
|
88
92
|
# Remove the earliest timer from the heap:
|
89
93
|
@heap.pop
|
90
94
|
|
data/lib/io/event/version.rb
CHANGED
data/readme.md
CHANGED
@@ -6,7 +6,7 @@ Provides low level cross-platform primitives for constructing event loops, with
|
|
6
6
|
|
7
7
|
## Motivation
|
8
8
|
|
9
|
-
The initial proof-of-concept [Async](https://github.com/socketry/async) was built on [NIO4r](https://github.com/socketry/nio4r). It was perfectly acceptable and well tested in production, however being built on `libev` was a little bit limiting. I wanted to directly
|
9
|
+
The initial proof-of-concept [Async](https://github.com/socketry/async) was built on [NIO4r](https://github.com/socketry/nio4r). It was perfectly acceptable and well tested in production, however being built on `libev` was a little bit limiting. I wanted to directly build my fiber scheduler into the fabric of the event loop, which is what this gem exposes - it is specifically implemented to support building event loops beneath the fiber scheduler interface, providing an efficient C implementation of all the core operations.
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -44,7 +44,7 @@ cert_chain:
|
|
44
44
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
45
45
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
46
46
|
-----END CERTIFICATE-----
|
47
|
-
date: 2024-06-
|
47
|
+
date: 2024-06-12 00:00:00.000000000 Z
|
48
48
|
dependencies: []
|
49
49
|
description:
|
50
50
|
email:
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.5.
|
104
|
+
rubygems_version: 3.5.9
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: An event loop.
|
metadata.gz.sig
CHANGED
Binary file
|