io-event 1.6.1 → 1.6.2
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 -8
- data/ext/io/event/selector/kqueue.c +8 -8
- data/ext/io/event/selector/selector.h +3 -2
- data/ext/io/event/selector/uring.c +8 -8
- data/lib/io/event/timers.rb +15 -11
- data/lib/io/event/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: 45049c22b990de175e733bdcce4045d7c4028dd50fa8018ec03b76ec76bfe1f2
|
4
|
+
data.tar.gz: 250555adf9d939804cc19f050e8cc42d9f2848e90f75cbcf46abc6543a67dbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed43ce7a15045fbad357e4e8b6eb176635ebd4148a2d3a5c229cc9af6c246f3d5bd0c8a80969f0a487fac468365b040888ef1e104275e0c82ef2397923bd24e3
|
7
|
+
data.tar.gz: 7d36cf2bb3f8dbdddba94564057b767415ff8da2884c8810c2b88e5dae1162a5f17f7bc538a8f766e1be6c6fb14e0fd213f08182b8e8e29e1fea77292dc8f37d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/extconf.rb
CHANGED
@@ -786,14 +786,7 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
786
786
|
return NULL;
|
787
787
|
}
|
788
788
|
|
789
|
-
if (
|
790
|
-
storage->tv_sec = NUM2TIMET(duration);
|
791
|
-
storage->tv_nsec = 0;
|
792
|
-
|
793
|
-
return storage;
|
794
|
-
}
|
795
|
-
|
796
|
-
else if (RB_FLOAT_TYPE_P(duration)) {
|
789
|
+
if (RB_FLOAT_TYPE_P(duration)) {
|
797
790
|
double value = RFLOAT_VALUE(duration);
|
798
791
|
time_t seconds = value;
|
799
792
|
|
@@ -803,6 +796,13 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
803
796
|
return storage;
|
804
797
|
}
|
805
798
|
|
799
|
+
else if (RB_INTEGER_TYPE_P(duration)) {
|
800
|
+
storage->tv_sec = NUM2TIMET(duration);
|
801
|
+
storage->tv_nsec = 0;
|
802
|
+
|
803
|
+
return storage;
|
804
|
+
}
|
805
|
+
|
806
806
|
rb_raise(rb_eArgError, "unable to convert timeout: %"PRIsVALUE, rb_inspect(duration));
|
807
807
|
}
|
808
808
|
|
@@ -799,14 +799,7 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
799
799
|
return NULL;
|
800
800
|
}
|
801
801
|
|
802
|
-
if (
|
803
|
-
storage->tv_sec = NUM2TIMET(duration);
|
804
|
-
storage->tv_nsec = 0;
|
805
|
-
|
806
|
-
return storage;
|
807
|
-
}
|
808
|
-
|
809
|
-
else if (RB_FLOAT_TYPE_P(duration)) {
|
802
|
+
if (RB_FLOAT_TYPE_P(duration)) {
|
810
803
|
double value = RFLOAT_VALUE(duration);
|
811
804
|
time_t seconds = value;
|
812
805
|
|
@@ -816,6 +809,13 @@ struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
|
816
809
|
return storage;
|
817
810
|
}
|
818
811
|
|
812
|
+
else if (RB_INTEGER_TYPE_P(duration)) {
|
813
|
+
storage->tv_sec = NUM2TIMET(duration);
|
814
|
+
storage->tv_nsec = 0;
|
815
|
+
|
816
|
+
return storage;
|
817
|
+
}
|
818
|
+
|
819
819
|
rb_raise(rb_eArgError, "unable to convert timeout: %"PRIsVALUE, rb_inspect(duration));
|
820
820
|
}
|
821
821
|
|
@@ -901,14 +901,7 @@ struct __kernel_timespec * make_timeout(VALUE duration, struct __kernel_timespec
|
|
901
901
|
return NULL;
|
902
902
|
}
|
903
903
|
|
904
|
-
if (
|
905
|
-
storage->tv_sec = NUM2TIMET(duration);
|
906
|
-
storage->tv_nsec = 0;
|
907
|
-
|
908
|
-
return storage;
|
909
|
-
}
|
910
|
-
|
911
|
-
else if (RB_FLOAT_TYPE_P(duration)) {
|
904
|
+
if (RB_FLOAT_TYPE_P(duration)) {
|
912
905
|
double value = RFLOAT_VALUE(duration);
|
913
906
|
time_t seconds = value;
|
914
907
|
|
@@ -918,6 +911,13 @@ struct __kernel_timespec * make_timeout(VALUE duration, struct __kernel_timespec
|
|
918
911
|
return storage;
|
919
912
|
}
|
920
913
|
|
914
|
+
else if (RB_INTEGER_TYPE_P(duration)) {
|
915
|
+
storage->tv_sec = NUM2TIMET(duration);
|
916
|
+
storage->tv_nsec = 0;
|
917
|
+
|
918
|
+
return storage;
|
919
|
+
}
|
920
|
+
|
921
921
|
rb_raise(rb_eArgError, "unable to convert timeout: %"PRIsVALUE, rb_inspect(duration));
|
922
922
|
}
|
923
923
|
|
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.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|