io-event 1.1.7 → 1.2.0
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 +1 -0
- data/ext/io/event/selector/epoll.c +64 -2
- data/ext/io/event/selector/selector.h +1 -1
- data/lib/io/event/version.rb +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: c19fdf43c5e63eb628c4ebb1feedcd048eac2e3ec4b83571f05bcb239eed9d02
|
4
|
+
data.tar.gz: 141749bc238099c65ebcc6db1d0d8b8ce1c3477e6e11a9f62e6c50572b9b6d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3da16be3fd6a0f98106f3e263ff2229e61a03bf5660fee1d3bb1bf6c191f1fd7475aabb85c8b5c29b25f6205816c728b42d68c74e4a123cea6810ac7be44b23
|
7
|
+
data.tar.gz: '026937a0ad18ba0f2783a8e8b8624177e8fbae34ca1a52eb2c5ccd59ae8231d4eea192fc3cc6b54d60e7d5d40d630f97754afa12e115f9ac44bd79caa9e52eee'
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/ext/extconf.rb
CHANGED
@@ -569,6 +569,38 @@ VALUE IO_Event_Selector_EPoll_io_write_compatible(int argc, VALUE *argv, VALUE s
|
|
569
569
|
|
570
570
|
#endif
|
571
571
|
|
572
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
573
|
+
static
|
574
|
+
struct timespec * make_timeout(VALUE duration, struct timespec * storage) {
|
575
|
+
if (duration == Qnil) {
|
576
|
+
return NULL;
|
577
|
+
}
|
578
|
+
|
579
|
+
if (FIXNUM_P(duration)) {
|
580
|
+
storage->tv_sec = NUM2TIMET(duration);
|
581
|
+
storage->tv_nsec = 0;
|
582
|
+
|
583
|
+
return storage;
|
584
|
+
}
|
585
|
+
|
586
|
+
else if (RB_FLOAT_TYPE_P(duration)) {
|
587
|
+
double value = RFLOAT_VALUE(duration);
|
588
|
+
time_t seconds = value;
|
589
|
+
|
590
|
+
storage->tv_sec = seconds;
|
591
|
+
storage->tv_nsec = (value - seconds) * 1000000000L;
|
592
|
+
|
593
|
+
return storage;
|
594
|
+
}
|
595
|
+
|
596
|
+
rb_raise(rb_eRuntimeError, "unable to convert timeout");
|
597
|
+
}
|
598
|
+
|
599
|
+
static
|
600
|
+
int timeout_nonblocking(struct timespec * timespec) {
|
601
|
+
return timespec && timespec->tv_sec == 0 && timespec->tv_nsec == 0;
|
602
|
+
}
|
603
|
+
#else
|
572
604
|
static
|
573
605
|
int make_timeout(VALUE duration) {
|
574
606
|
if (duration == Qnil) {
|
@@ -588,20 +620,35 @@ int make_timeout(VALUE duration) {
|
|
588
620
|
rb_raise(rb_eRuntimeError, "unable to convert timeout");
|
589
621
|
}
|
590
622
|
|
623
|
+
static
|
624
|
+
int timeout_nonblocking(int timeout) {
|
625
|
+
return timeout == 0;
|
626
|
+
}
|
627
|
+
#endif
|
628
|
+
|
591
629
|
struct select_arguments {
|
592
630
|
struct IO_Event_Selector_EPoll *data;
|
593
631
|
|
594
632
|
int count;
|
595
633
|
struct epoll_event events[EPOLL_MAX_EVENTS];
|
596
|
-
|
634
|
+
|
635
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
636
|
+
struct timespec * timeout;
|
637
|
+
struct timespec storage;
|
638
|
+
#else
|
597
639
|
int timeout;
|
640
|
+
#endif
|
598
641
|
};
|
599
642
|
|
600
643
|
static
|
601
644
|
void * select_internal(void *_arguments) {
|
602
645
|
struct select_arguments * arguments = (struct select_arguments *)_arguments;
|
603
646
|
|
647
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
648
|
+
arguments->count = epoll_pwait2(arguments->data->descriptor, arguments->events, EPOLL_MAX_EVENTS, arguments->timeout, NULL);
|
649
|
+
#else
|
604
650
|
arguments->count = epoll_wait(arguments->data->descriptor, arguments->events, EPOLL_MAX_EVENTS, arguments->timeout);
|
651
|
+
#endif
|
605
652
|
|
606
653
|
return NULL;
|
607
654
|
}
|
@@ -642,9 +689,20 @@ VALUE IO_Event_Selector_EPoll_select(VALUE self, VALUE duration) {
|
|
642
689
|
|
643
690
|
struct select_arguments arguments = {
|
644
691
|
.data = data,
|
692
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
693
|
+
.storage = {
|
694
|
+
.tv_sec = 0,
|
695
|
+
.tv_nsec = 0
|
696
|
+
}
|
697
|
+
#else
|
645
698
|
.timeout = 0
|
699
|
+
#endif
|
646
700
|
};
|
647
701
|
|
702
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
703
|
+
arguments.timeout = &arguments.storage;
|
704
|
+
#endif
|
705
|
+
|
648
706
|
// Process any currently pending events:
|
649
707
|
select_internal_with_gvl(&arguments);
|
650
708
|
|
@@ -654,9 +712,13 @@ VALUE IO_Event_Selector_EPoll_select(VALUE self, VALUE duration) {
|
|
654
712
|
// 3. There are no items in the ready list,
|
655
713
|
// then we can perform a blocking select.
|
656
714
|
if (!ready && !arguments.count && !data->backend.ready) {
|
715
|
+
#if defined(HAVE_EPOLL_PWAIT2)
|
716
|
+
arguments.timeout = make_timeout(duration, &arguments.storage);
|
717
|
+
#else
|
657
718
|
arguments.timeout = make_timeout(duration);
|
719
|
+
#endif
|
658
720
|
|
659
|
-
if (arguments.timeout
|
721
|
+
if (!timeout_nonblocking(arguments.timeout)) {
|
660
722
|
// Wait for events to occur
|
661
723
|
select_internal_without_gvl(&arguments);
|
662
724
|
}
|
data/lib/io/event/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
42
42
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date: 2023-
|
44
|
+
date: 2023-04-30 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bake
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.4.
|
153
|
+
rubygems_version: 3.4.10
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: An event loop.
|
metadata.gz.sig
CHANGED
Binary file
|