uringmachine 0.14 → 0.15
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
- data/CHANGELOG.md +4 -0
- data/ext/um/um.c +7 -3
- data/ext/um/um_class.c +1 -1
- data/lib/uringmachine/version.rb +1 -1
- data/test/test_um.rb +17 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b3778bbf3b35b2f0855c5fdbe441df909a43866c56ceed16cacf502956566ba
|
4
|
+
data.tar.gz: 82b580cb610c11d5d05e69ab868ba70265fec92851cbdca7cf340bbde09c0b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82fbdc455e76bd1adaf4668ae0d43c8c1e84f9c168c1d3e2f7a4924e672d5b77617ce720ac6fcb9257cc8e8edcf419f4267acdd7128d72a5d03c0b808f85ab4b
|
7
|
+
data.tar.gz: d56ba947a2d6ba974faa7e0594b506e0f7520815a995e263a7a9acf0658b73c057bd7d13f32e035376a4871dea6ff7824d04a621957707cb56a6f7e92581af1d
|
data/CHANGELOG.md
CHANGED
data/ext/um/um.c
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#include <float.h>
|
1
2
|
#include "um.h"
|
2
3
|
#include "ruby/thread.h"
|
3
4
|
|
@@ -317,7 +318,11 @@ VALUE um_timeout(struct um *machine, VALUE interval, VALUE class) {
|
|
317
318
|
blocking singleshot ops
|
318
319
|
*******************************************************************************/
|
319
320
|
|
321
|
+
#define SLEEP_FOREVER_DURATION (86400*10000)
|
322
|
+
|
320
323
|
VALUE um_sleep(struct um *machine, double duration) {
|
324
|
+
if (duration <= 0) duration = SLEEP_FOREVER_DURATION;
|
325
|
+
|
321
326
|
struct um_op op;
|
322
327
|
um_prep_op(machine, &op, OP_SLEEP, 0);
|
323
328
|
op.ts = um_double_to_timespec(duration);
|
@@ -416,7 +421,7 @@ VALUE um_close(struct um *machine, int fd) {
|
|
416
421
|
VALUE um_close_async(struct um *machine, int fd) {
|
417
422
|
struct um_op *op = um_op_alloc(machine);
|
418
423
|
um_prep_op(machine, op, OP_CLOSE_ASYNC, OP_F_FREE_ON_COMPLETE);
|
419
|
-
|
424
|
+
|
420
425
|
struct io_uring_sqe *sqe = um_get_sqe(machine, op);
|
421
426
|
io_uring_prep_close(sqe, fd);
|
422
427
|
|
@@ -593,7 +598,7 @@ VALUE um_shutdown(struct um *machine, int fd, int how) {
|
|
593
598
|
VALUE um_shutdown_async(struct um *machine, int fd, int how) {
|
594
599
|
struct um_op *op = um_op_alloc(machine);
|
595
600
|
um_prep_op(machine, op, OP_SHUTDOWN_ASYNC, OP_F_FREE_ON_COMPLETE);
|
596
|
-
|
601
|
+
|
597
602
|
struct io_uring_sqe *sqe = um_get_sqe(machine, op);
|
598
603
|
io_uring_prep_shutdown(sqe, fd, how);
|
599
604
|
|
@@ -888,4 +893,3 @@ VALUE um_periodically(struct um *machine, double interval) {
|
|
888
893
|
struct op_ctx ctx = { .machine = machine, .op = &op, .ts = op.ts, .read_buf = NULL };
|
889
894
|
return rb_ensure(periodically_start, (VALUE)&ctx, multishot_complete, (VALUE)&ctx);
|
890
895
|
}
|
891
|
-
|
data/ext/um/um_class.c
CHANGED
data/lib/uringmachine/version.rb
CHANGED
data/test/test_um.rb
CHANGED
@@ -234,6 +234,20 @@ class SleepTest < UMBaseTest
|
|
234
234
|
assert_in_range 0.02..0.04, t1 - t0
|
235
235
|
assert_kind_of D, ret
|
236
236
|
end
|
237
|
+
|
238
|
+
def test_sleep_forever
|
239
|
+
t0 = monotonic_clock
|
240
|
+
ret = begin
|
241
|
+
machine.timeout(0.03, D) do
|
242
|
+
machine.sleep 0
|
243
|
+
end
|
244
|
+
rescue => e
|
245
|
+
e
|
246
|
+
end
|
247
|
+
t1 = monotonic_clock
|
248
|
+
assert_in_range 0.02..0.04, t1 - t0
|
249
|
+
assert_kind_of D, ret
|
250
|
+
end
|
237
251
|
end
|
238
252
|
|
239
253
|
class PeriodicallyTest < UMBaseTest
|
@@ -579,7 +593,7 @@ class CloseTest < UMBaseTest
|
|
579
593
|
def test_close_bad_fd
|
580
594
|
r, w = IO.pipe
|
581
595
|
machine.close(w.fileno)
|
582
|
-
|
596
|
+
|
583
597
|
assert_raises(Errno::EBADF) { machine.close(w.fileno) }
|
584
598
|
end
|
585
599
|
end
|
@@ -1316,7 +1330,7 @@ class WaitTest < UMBaseTest
|
|
1316
1330
|
ret = machine.read(rfd, buf, 8192)
|
1317
1331
|
assert_equal msg.bytesize, ret
|
1318
1332
|
assert_equal msg, buf
|
1319
|
-
|
1333
|
+
|
1320
1334
|
ensure
|
1321
1335
|
Process.wait(pid) rescue Errno::ECHILD
|
1322
1336
|
end
|
@@ -1404,4 +1418,4 @@ class ForkTest < UMBaseTest
|
|
1404
1418
|
Process.wait(child_pid) rescue Errno::ECHILD
|
1405
1419
|
end
|
1406
1420
|
|
1407
|
-
end
|
1421
|
+
end
|