polyphony 0.93 → 0.95
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/.github/workflows/test.yml +2 -2
- data/.gitignore +3 -3
- data/CHANGELOG.md +14 -0
- data/docs/api-reference/fiber.md +2 -2
- data/docs/api-reference/object.md +3 -3
- data/docs/main-concepts/exception-handling.md +2 -2
- data/examples/pipes/echo_server.rb +1 -1
- data/examples/pipes/http_server.rb +33 -0
- data/ext/polyphony/backend_common.c +53 -8
- data/ext/polyphony/backend_common.h +21 -13
- data/ext/polyphony/backend_io_uring.c +85 -147
- data/ext/polyphony/backend_libev.c +58 -89
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +7 -5
- data/ext/polyphony/fiber.c +5 -13
- data/ext/polyphony/io_extensions.c +68 -68
- data/ext/polyphony/pipe.c +1 -1
- data/ext/polyphony/polyphony.c +23 -23
- data/ext/polyphony/polyphony.h +0 -9
- data/ext/polyphony/polyphony_ext.c +1 -1
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/ring_buffer.c +1 -0
- data/ext/polyphony/socket_extensions.c +1 -1
- data/ext/polyphony/thread.c +1 -1
- data/lib/polyphony/extensions/enumerator.rb +16 -0
- data/lib/polyphony/extensions/socket.rb +2 -0
- data/lib/polyphony/extensions.rb +1 -0
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +2 -2
- data/test/test_backend.rb +5 -1
- data/test/test_enumerator.rb +46 -0
- data/test/test_global_api.rb +1 -1
- data/test/test_io.rb +241 -216
- data/test/test_socket.rb +1 -1
- data/test/test_thread_pool.rb +3 -3
- data/vendor/liburing/.github/workflows/build.yml +51 -5
- data/vendor/liburing/.github/workflows/shellcheck.yml +1 -1
- data/vendor/liburing/.gitignore +6 -123
- data/vendor/liburing/CHANGELOG +35 -0
- data/vendor/liburing/CITATION.cff +11 -0
- data/vendor/liburing/LICENSE +16 -3
- data/vendor/liburing/Makefile +3 -1
- data/vendor/liburing/Makefile.common +1 -0
- data/vendor/liburing/README +14 -2
- data/vendor/liburing/SECURITY.md +6 -0
- data/vendor/liburing/configure +16 -15
- data/vendor/liburing/examples/Makefile +4 -1
- data/vendor/liburing/examples/io_uring-udp.c +395 -0
- data/vendor/liburing/examples/poll-bench.c +101 -0
- data/vendor/liburing/examples/send-zerocopy.c +339 -0
- data/vendor/liburing/liburing.spec +1 -1
- data/vendor/liburing/man/io_uring.7 +38 -11
- data/vendor/liburing/man/io_uring_buf_ring_add.3 +53 -0
- data/vendor/liburing/man/io_uring_buf_ring_advance.3 +31 -0
- data/vendor/liburing/man/io_uring_buf_ring_cq_advance.3 +41 -0
- data/vendor/liburing/man/io_uring_buf_ring_init.3 +30 -0
- data/vendor/liburing/man/io_uring_buf_ring_mask.3 +27 -0
- data/vendor/liburing/man/io_uring_cq_advance.3 +29 -15
- data/vendor/liburing/man/io_uring_cq_has_overflow.3 +25 -0
- data/vendor/liburing/man/io_uring_cq_ready.3 +9 -8
- data/vendor/liburing/man/io_uring_cqe_get_data.3 +32 -13
- data/vendor/liburing/man/io_uring_cqe_get_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_cqe_seen.3 +22 -12
- data/vendor/liburing/man/io_uring_enter.2 +249 -32
- data/vendor/liburing/man/io_uring_enter2.2 +1 -0
- data/vendor/liburing/man/io_uring_free_probe.3 +11 -8
- data/vendor/liburing/man/io_uring_get_events.3 +33 -0
- data/vendor/liburing/man/io_uring_get_probe.3 +9 -8
- data/vendor/liburing/man/io_uring_get_sqe.3 +29 -10
- data/vendor/liburing/man/io_uring_opcode_supported.3 +11 -10
- data/vendor/liburing/man/io_uring_peek_cqe.3 +38 -0
- data/vendor/liburing/man/io_uring_prep_accept.3 +197 -0
- data/vendor/liburing/man/io_uring_prep_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_cancel.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_cancel64.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_close.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_close_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_connect.3 +66 -0
- data/vendor/liburing/man/io_uring_prep_fadvise.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_fallocate.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_files_update.3 +92 -0
- data/vendor/liburing/man/io_uring_prep_fsync.3 +70 -0
- data/vendor/liburing/man/io_uring_prep_link.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_linkat.3 +91 -0
- data/vendor/liburing/man/io_uring_prep_madvise.3 +56 -0
- data/vendor/liburing/man/io_uring_prep_mkdir.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_mkdirat.3 +83 -0
- data/vendor/liburing/man/io_uring_prep_msg_ring.3 +39 -25
- data/vendor/liburing/man/io_uring_prep_multishot_accept.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_multishot_accept_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_nop.3 +28 -0
- data/vendor/liburing/man/io_uring_prep_openat.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2.3 +117 -0
- data/vendor/liburing/man/io_uring_prep_openat2_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_openat_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_add.3 +72 -0
- data/vendor/liburing/man/io_uring_prep_poll_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_poll_remove.3 +55 -0
- data/vendor/liburing/man/io_uring_prep_poll_update.3 +89 -0
- data/vendor/liburing/man/io_uring_prep_provide_buffers.3 +131 -0
- data/vendor/liburing/man/io_uring_prep_read.3 +33 -14
- data/vendor/liburing/man/io_uring_prep_read_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_readv.3 +49 -15
- data/vendor/liburing/man/io_uring_prep_readv2.3 +49 -17
- data/vendor/liburing/man/io_uring_prep_recv.3 +105 -0
- data/vendor/liburing/man/io_uring_prep_recv_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg.3 +124 -0
- data/vendor/liburing/man/io_uring_prep_recvmsg_multishot.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_remove_buffers.3 +52 -0
- data/vendor/liburing/man/io_uring_prep_rename.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_renameat.3 +96 -0
- data/vendor/liburing/man/io_uring_prep_send.3 +57 -0
- data/vendor/liburing/man/io_uring_prep_send_zc.3 +64 -0
- data/vendor/liburing/man/io_uring_prep_sendmsg.3 +69 -0
- data/vendor/liburing/man/io_uring_prep_shutdown.3 +53 -0
- data/vendor/liburing/man/io_uring_prep_socket.3 +118 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_socket_direct_alloc.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_splice.3 +80 -0
- data/vendor/liburing/man/io_uring_prep_statx.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_symlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_symlinkat.3 +85 -0
- data/vendor/liburing/man/io_uring_prep_sync_file_range.3 +59 -0
- data/vendor/liburing/man/io_uring_prep_tee.3 +74 -0
- data/vendor/liburing/man/io_uring_prep_timeout.3 +95 -0
- data/vendor/liburing/man/io_uring_prep_timeout_remove.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_timeout_update.3 +98 -0
- data/vendor/liburing/man/io_uring_prep_unlink.3 +1 -0
- data/vendor/liburing/man/io_uring_prep_unlinkat.3 +82 -0
- data/vendor/liburing/man/io_uring_prep_write.3 +32 -15
- data/vendor/liburing/man/io_uring_prep_write_fixed.3 +39 -21
- data/vendor/liburing/man/io_uring_prep_writev.3 +50 -16
- data/vendor/liburing/man/io_uring_prep_writev2.3 +50 -17
- data/vendor/liburing/man/io_uring_queue_exit.3 +3 -4
- data/vendor/liburing/man/io_uring_queue_init.3 +58 -13
- data/vendor/liburing/man/io_uring_queue_init_params.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_firsthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_cmsg_nexthdr.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_name.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_out.3 +78 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_payload_length.3 +1 -0
- data/vendor/liburing/man/io_uring_recvmsg_validate.3 +1 -0
- data/vendor/liburing/man/io_uring_register.2 +153 -13
- data/vendor/liburing/man/io_uring_register_buf_ring.3 +140 -0
- data/vendor/liburing/man/io_uring_register_buffers.3 +32 -12
- data/vendor/liburing/man/io_uring_register_eventfd.3 +51 -0
- data/vendor/liburing/man/io_uring_register_eventfd_async.3 +1 -0
- data/vendor/liburing/man/io_uring_register_file_alloc_range.3 +52 -0
- data/vendor/liburing/man/io_uring_register_files.3 +33 -11
- data/vendor/liburing/man/io_uring_register_files_sparse.3 +1 -0
- data/vendor/liburing/man/io_uring_register_iowq_aff.3 +61 -0
- data/vendor/liburing/man/io_uring_register_iowq_max_workers.3 +71 -0
- data/vendor/liburing/man/io_uring_register_ring_fd.3 +49 -0
- data/vendor/liburing/man/io_uring_register_sync_cancel.3 +71 -0
- data/vendor/liburing/man/io_uring_setup.2 +119 -13
- data/vendor/liburing/man/io_uring_sq_ready.3 +14 -8
- data/vendor/liburing/man/io_uring_sq_space_left.3 +9 -9
- data/vendor/liburing/man/io_uring_sqe_set_data.3 +29 -11
- data/vendor/liburing/man/io_uring_sqe_set_data64.3 +1 -0
- data/vendor/liburing/man/io_uring_sqe_set_flags.3 +38 -11
- data/vendor/liburing/man/io_uring_sqring_wait.3 +13 -9
- data/vendor/liburing/man/io_uring_submit.3 +29 -12
- data/vendor/liburing/man/io_uring_submit_and_get_events.3 +31 -0
- data/vendor/liburing/man/io_uring_submit_and_wait.3 +16 -12
- data/vendor/liburing/man/io_uring_submit_and_wait_timeout.3 +30 -23
- data/vendor/liburing/man/io_uring_unregister_buf_ring.3 +30 -0
- data/vendor/liburing/man/io_uring_unregister_buffers.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_eventfd.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_files.3 +11 -10
- data/vendor/liburing/man/io_uring_unregister_iowq_aff.3 +1 -0
- data/vendor/liburing/man/io_uring_unregister_ring_fd.3 +32 -0
- data/vendor/liburing/man/io_uring_wait_cqe.3 +19 -12
- data/vendor/liburing/man/io_uring_wait_cqe_nr.3 +21 -14
- data/vendor/liburing/man/io_uring_wait_cqe_timeout.3 +27 -13
- data/vendor/liburing/man/io_uring_wait_cqes.3 +24 -14
- data/vendor/liburing/src/Makefile +8 -7
- data/vendor/liburing/src/arch/aarch64/lib.h +48 -0
- data/vendor/liburing/src/arch/aarch64/syscall.h +0 -4
- data/vendor/liburing/src/arch/generic/lib.h +0 -4
- data/vendor/liburing/src/arch/generic/syscall.h +29 -16
- data/vendor/liburing/src/arch/syscall-defs.h +41 -14
- data/vendor/liburing/src/arch/x86/lib.h +0 -21
- data/vendor/liburing/src/arch/x86/syscall.h +146 -10
- data/vendor/liburing/src/include/liburing/io_uring.h +245 -5
- data/vendor/liburing/src/include/liburing.h +468 -35
- data/vendor/liburing/src/int_flags.h +1 -0
- data/vendor/liburing/src/lib.h +20 -16
- data/vendor/liburing/src/liburing.map +16 -0
- data/vendor/liburing/src/nolibc.c +1 -1
- data/vendor/liburing/src/queue.c +87 -55
- data/vendor/liburing/src/register.c +129 -53
- data/vendor/liburing/src/setup.c +65 -28
- data/vendor/liburing/src/syscall.c +14 -32
- data/vendor/liburing/src/syscall.h +12 -64
- data/vendor/liburing/test/{232c93d07b74-test.c → 232c93d07b74.c} +8 -9
- data/vendor/liburing/test/{35fa71a030ca-test.c → 35fa71a030ca.c} +4 -4
- data/vendor/liburing/test/{500f9fbadef8-test.c → 500f9fbadef8.c} +7 -7
- data/vendor/liburing/test/{7ad0e4b2f83c-test.c → 7ad0e4b2f83c.c} +8 -7
- data/vendor/liburing/test/{8a9973408177-test.c → 8a9973408177.c} +4 -3
- data/vendor/liburing/test/{917257daa0fe-test.c → 917257daa0fe.c} +3 -2
- data/vendor/liburing/test/Makefile +60 -62
- data/vendor/liburing/test/{a0908ae19763-test.c → a0908ae19763.c} +3 -2
- data/vendor/liburing/test/{a4c0b3decb33-test.c → a4c0b3decb33.c} +3 -2
- data/vendor/liburing/test/accept-link.c +5 -4
- data/vendor/liburing/test/accept-reuse.c +17 -16
- data/vendor/liburing/test/accept-test.c +14 -10
- data/vendor/liburing/test/accept.c +529 -107
- data/vendor/liburing/test/across-fork.c +7 -6
- data/vendor/liburing/test/{b19062a56726-test.c → b19062a56726.c} +3 -2
- data/vendor/liburing/test/{b5837bd5311d-test.c → b5837bd5311d.c} +10 -9
- data/vendor/liburing/test/buf-ring.c +420 -0
- data/vendor/liburing/test/{ce593a6c480a-test.c → ce593a6c480a.c} +15 -12
- data/vendor/liburing/test/connect.c +8 -7
- data/vendor/liburing/test/cq-full.c +5 -4
- data/vendor/liburing/test/cq-overflow.c +242 -12
- data/vendor/liburing/test/cq-peek-batch.c +5 -4
- data/vendor/liburing/test/cq-ready.c +5 -4
- data/vendor/liburing/test/cq-size.c +5 -4
- data/vendor/liburing/test/{d4ae271dfaae-test.c → d4ae271dfaae.c} +2 -2
- data/vendor/liburing/test/{d77a67ed5f27-test.c → d77a67ed5f27.c} +6 -6
- data/vendor/liburing/test/defer-taskrun.c +336 -0
- data/vendor/liburing/test/defer.c +26 -14
- data/vendor/liburing/test/double-poll-crash.c +15 -5
- data/vendor/liburing/test/drop-submit.c +5 -3
- data/vendor/liburing/test/{eeed8b54e0df-test.c → eeed8b54e0df.c} +7 -6
- data/vendor/liburing/test/empty-eownerdead.c +4 -4
- data/vendor/liburing/test/eventfd-disable.c +48 -20
- data/vendor/liburing/test/eventfd-reg.c +10 -9
- data/vendor/liburing/test/eventfd-ring.c +13 -12
- data/vendor/liburing/test/eventfd.c +13 -12
- data/vendor/liburing/test/exit-no-cleanup.c +1 -1
- data/vendor/liburing/test/fadvise.c +3 -3
- data/vendor/liburing/test/fallocate.c +16 -9
- data/vendor/liburing/test/{fc2a85cb02ef-test.c → fc2a85cb02ef.c} +4 -3
- data/vendor/liburing/test/fd-pass.c +187 -0
- data/vendor/liburing/test/file-register.c +302 -36
- data/vendor/liburing/test/file-update.c +62 -4
- data/vendor/liburing/test/file-verify.c +6 -2
- data/vendor/liburing/test/files-exit-hang-poll.c +11 -25
- data/vendor/liburing/test/files-exit-hang-timeout.c +13 -10
- data/vendor/liburing/test/fixed-buf-iter.c +115 -0
- data/vendor/liburing/test/fixed-link.c +10 -10
- data/vendor/liburing/test/fixed-reuse.c +160 -0
- data/vendor/liburing/test/fpos.c +6 -3
- data/vendor/liburing/test/fsync.c +3 -3
- data/vendor/liburing/test/hardlink.c +10 -6
- data/vendor/liburing/test/helpers.c +137 -4
- data/vendor/liburing/test/helpers.h +27 -0
- data/vendor/liburing/test/io-cancel.c +16 -11
- data/vendor/liburing/test/io_uring_enter.c +46 -81
- data/vendor/liburing/test/io_uring_passthrough.c +451 -0
- data/vendor/liburing/test/io_uring_register.c +59 -229
- data/vendor/liburing/test/io_uring_setup.c +24 -29
- data/vendor/liburing/test/iopoll-leak.c +85 -0
- data/vendor/liburing/test/iopoll.c +16 -9
- data/vendor/liburing/test/lfs-openat-write.c +3 -1
- data/vendor/liburing/test/link-timeout.c +4 -3
- data/vendor/liburing/test/link.c +8 -7
- data/vendor/liburing/test/madvise.c +2 -2
- data/vendor/liburing/test/mkdir.c +9 -5
- data/vendor/liburing/test/msg-ring.c +46 -20
- data/vendor/liburing/test/multicqes_drain.c +51 -12
- data/vendor/liburing/test/nolibc.c +60 -0
- data/vendor/liburing/test/nop.c +78 -16
- data/vendor/liburing/test/nvme.h +168 -0
- data/vendor/liburing/test/open-direct-link.c +188 -0
- data/vendor/liburing/test/open-direct-pick.c +180 -0
- data/vendor/liburing/test/openat2.c +3 -3
- data/vendor/liburing/test/poll-cancel-all.c +472 -0
- data/vendor/liburing/test/poll-link.c +9 -18
- data/vendor/liburing/test/poll-mshot-overflow.c +162 -0
- data/vendor/liburing/test/poll-mshot-update.c +83 -33
- data/vendor/liburing/test/pollfree.c +2 -2
- data/vendor/liburing/test/read-before-exit.c +112 -0
- data/vendor/liburing/test/read-write.c +83 -1
- data/vendor/liburing/test/recv-msgall-stream.c +398 -0
- data/vendor/liburing/test/recv-msgall.c +265 -0
- data/vendor/liburing/test/recv-multishot.c +505 -0
- data/vendor/liburing/test/rename.c +2 -5
- data/vendor/liburing/test/ring-leak.c +97 -0
- data/vendor/liburing/test/ringbuf-read.c +200 -0
- data/vendor/liburing/test/rsrc_tags.c +25 -13
- data/vendor/liburing/test/runtests-quiet.sh +11 -0
- data/vendor/liburing/test/runtests.sh +18 -20
- data/vendor/liburing/test/rw_merge_test.c +3 -2
- data/vendor/liburing/test/send-zerocopy.c +684 -0
- data/vendor/liburing/test/send_recv.c +49 -2
- data/vendor/liburing/test/send_recvmsg.c +165 -55
- data/vendor/liburing/test/shutdown.c +3 -4
- data/vendor/liburing/test/sigfd-deadlock.c +22 -8
- data/vendor/liburing/test/single-issuer.c +171 -0
- data/vendor/liburing/test/socket-rw-eagain.c +2 -12
- data/vendor/liburing/test/socket-rw-offset.c +2 -11
- data/vendor/liburing/test/socket-rw.c +2 -11
- data/vendor/liburing/test/socket.c +409 -0
- data/vendor/liburing/test/sq-poll-dup.c +1 -1
- data/vendor/liburing/test/sq-poll-share.c +1 -1
- data/vendor/liburing/test/statx.c +2 -2
- data/vendor/liburing/test/submit-and-wait.c +108 -0
- data/vendor/liburing/test/submit-link-fail.c +5 -3
- data/vendor/liburing/test/submit-reuse.c +0 -2
- data/vendor/liburing/test/sync-cancel.c +235 -0
- data/vendor/liburing/test/test.h +35 -0
- data/vendor/liburing/test/timeout-overflow.c +11 -11
- data/vendor/liburing/test/timeout.c +7 -7
- data/vendor/liburing/test/tty-write-dpoll.c +60 -0
- data/vendor/liburing/test/unlink.c +1 -1
- data/vendor/liburing/test/xattr.c +425 -0
- metadata +148 -26
- data/Gemfile.lock +0 -82
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 554854ea3a7b1bc8dd555b24283e42019bb7bfb91953cd0b3e6ac49c9c59198b
|
|
4
|
+
data.tar.gz: 59a88ec85837e68ed50594ee892c814dee9e15ba19b4392d50436fb0b51b1d82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3637e9af046327dd642bb555224e4dd36169824a698b1176f57ebeb309e61d1ac6c50d2423c8ab2ac72abf9d8e9184f37ebf9ca8343032d7e40b3244d99f8ca7
|
|
7
|
+
data.tar.gz: 27fca71574396f73e783630691cbda094488ab19128c884ca2fdafd570b0df920f083e46750455a656c0f26c9acc6f11783634cb7d43b23f2689f000ee0c67ea
|
data/.github/workflows/test.yml
CHANGED
|
@@ -8,7 +8,7 @@ jobs:
|
|
|
8
8
|
fail-fast: false
|
|
9
9
|
matrix:
|
|
10
10
|
os: [ubuntu-latest, macos-latest]
|
|
11
|
-
ruby: ['
|
|
11
|
+
ruby: ['3.0', '3.1', '3.2']
|
|
12
12
|
|
|
13
13
|
name: >-
|
|
14
14
|
${{matrix.os}}, ${{matrix.ruby}}
|
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
22
|
- name: Setup machine
|
|
23
|
-
uses: actions/checkout@
|
|
23
|
+
uses: actions/checkout@v3
|
|
24
24
|
- name: Setup Ruby
|
|
25
25
|
uses: ruby/setup-ruby@v1
|
|
26
26
|
with:
|
data/.gitignore
CHANGED
|
@@ -42,9 +42,9 @@ build-iPhoneSimulator/
|
|
|
42
42
|
|
|
43
43
|
# for a library or gem, you might want to ignore these files since the code is
|
|
44
44
|
# intended to run in multiple environments; otherwise, check them in:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
Gemfile.lock
|
|
46
|
+
.ruby-version
|
|
47
|
+
.ruby-gemset
|
|
48
48
|
|
|
49
49
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
50
50
|
.rvmrc
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.95 2023-01-16
|
|
2
|
+
|
|
3
|
+
- Remove support for Ruby 2.7
|
|
4
|
+
- Add support for explicit Enumerator (external enumeration) (#93)
|
|
5
|
+
- Fix `Socket#readpartial`
|
|
6
|
+
- Fix `receive_all_pending` docs (#92)
|
|
7
|
+
- Improve linux kernel version detection
|
|
8
|
+
- Update liburing
|
|
9
|
+
- Always reset SQE user data in io_uring backend
|
|
10
|
+
|
|
11
|
+
## 0.94 2022-10-03
|
|
12
|
+
|
|
13
|
+
- Fix linux kernel version detection (#89)
|
|
14
|
+
|
|
1
15
|
## 0.93 2022-04-05
|
|
2
16
|
|
|
3
17
|
- Add support for IO::Buffer in Ruby 3.1 (#80)
|
data/docs/api-reference/fiber.md
CHANGED
|
@@ -212,7 +212,7 @@ spin { Fiber.current.parent << 'hello from child' }
|
|
|
212
212
|
message = receive #=> 'hello from child'
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
-
### #
|
|
215
|
+
### #receive_all_pending → [*object]
|
|
216
216
|
|
|
217
217
|
Returns all messages currently in the mailbox, emptying the mailbox. This method
|
|
218
218
|
does not block if no the mailbox is already empty. This method may be used to
|
|
@@ -225,7 +225,7 @@ worker = spin do
|
|
|
225
225
|
handle_job(job)
|
|
226
226
|
end
|
|
227
227
|
rescue Polyphony::Terminate => e
|
|
228
|
-
|
|
228
|
+
receive_all_pending.each { |job| handle_job(job) }
|
|
229
229
|
end
|
|
230
230
|
```
|
|
231
231
|
|
|
@@ -63,9 +63,9 @@ result #=> 'bar'
|
|
|
63
63
|
|
|
64
64
|
Shortcut for `Fiber.current.receive`
|
|
65
65
|
|
|
66
|
-
### #
|
|
66
|
+
### #receive_all_pending → [*object]
|
|
67
67
|
|
|
68
|
-
Shortcut for `Fiber.current.
|
|
68
|
+
Shortcut for `Fiber.current.receive_all_pending`
|
|
69
69
|
|
|
70
70
|
### #sleep(duration = nil) → fiber
|
|
71
71
|
|
|
@@ -96,4 +96,4 @@ returns. Otherwise, the loop is infinite (unless an exception is raised).
|
|
|
96
96
|
```ruby
|
|
97
97
|
# twice a second
|
|
98
98
|
throttled_loop(2) { puts 'hello world' }
|
|
99
|
-
```
|
|
99
|
+
```
|
|
@@ -229,7 +229,7 @@ def do_work
|
|
|
229
229
|
end
|
|
230
230
|
rescue Polyphony::Terminate
|
|
231
231
|
# We still need to handle any pending request
|
|
232
|
-
|
|
232
|
+
receive_all_pending.each { handle_req(req) }
|
|
233
233
|
end
|
|
234
234
|
|
|
235
235
|
# on the main fiber
|
|
@@ -288,4 +288,4 @@ loop.
|
|
|
288
288
|
To ensure proper thread termination, including the termination of all the
|
|
289
289
|
thread's fibers, Polyphony patches the `Thread#kill` and `Thread#raise` methods
|
|
290
290
|
to schedule the thread's main fiber with the corresponding exceptions, thus
|
|
291
|
-
ensuring an orderly termination or exception handling.
|
|
291
|
+
ensuring an orderly termination or exception handling.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/inline'
|
|
4
|
+
|
|
5
|
+
gemfile do
|
|
6
|
+
gem 'h1p'
|
|
7
|
+
gem 'polyphony', path: '.'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require 'polyphony'
|
|
11
|
+
require 'h1p'
|
|
12
|
+
|
|
13
|
+
def handle_client(conn)
|
|
14
|
+
spin do
|
|
15
|
+
parser = H1P::Parser.new(conn, :server)
|
|
16
|
+
|
|
17
|
+
while true # assuming persistent connection
|
|
18
|
+
headers = parser.parse_headers
|
|
19
|
+
break unless headers
|
|
20
|
+
|
|
21
|
+
parser.read_body unless parser.complete?
|
|
22
|
+
|
|
23
|
+
conn << "HTTP/1.1 200 OK\r\nContent-Length: 14\r\n\r\nHello, world!\n"
|
|
24
|
+
end
|
|
25
|
+
rescue H1P::Error
|
|
26
|
+
puts 'Got invalid request, closing connection...'
|
|
27
|
+
ensure
|
|
28
|
+
conn.close
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
puts "Serving HTTP on port 1234..."
|
|
33
|
+
TCPServer.new('0.0.0.0', 1234).accept_loop { |c| handle_client(c) }
|
|
@@ -280,7 +280,7 @@ inline void rectify_io_file_pos(rb_io_t *fptr) {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
inline double current_time() {
|
|
283
|
+
inline double current_time(void) {
|
|
284
284
|
struct timespec ts;
|
|
285
285
|
double t;
|
|
286
286
|
uint64_t ns;
|
|
@@ -292,7 +292,7 @@ inline double current_time() {
|
|
|
292
292
|
return t / 1e9;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
inline uint64_t current_time_ns() {
|
|
295
|
+
inline uint64_t current_time_ns(void) {
|
|
296
296
|
struct timespec ts;
|
|
297
297
|
uint64_t ns;
|
|
298
298
|
|
|
@@ -439,7 +439,7 @@ VALUE Backend_verify_blocking_mode(VALUE self, VALUE io, VALUE blocking) {
|
|
|
439
439
|
return self;
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
void backend_setup_stats_symbols() {
|
|
442
|
+
void backend_setup_stats_symbols(void) {
|
|
443
443
|
SYM_runqueue_size = ID2SYM(rb_intern("runqueue_size"));
|
|
444
444
|
SYM_runqueue_length = ID2SYM(rb_intern("runqueue_length"));
|
|
445
445
|
SYM_runqueue_max_length = ID2SYM(rb_intern("runqueue_max_length"));
|
|
@@ -479,10 +479,10 @@ int backend_getaddrinfo(VALUE host, VALUE port, struct sockaddr **ai_addr) {
|
|
|
479
479
|
return addrinfo_result->ai_addrlen;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
struct
|
|
482
|
+
inline struct backend_buffer_spec backend_get_buffer_spec(VALUE in, int rw) {
|
|
483
483
|
if (FIXNUM_P(in)) {
|
|
484
|
-
struct
|
|
485
|
-
return (struct
|
|
484
|
+
struct buffer_spec *spec = FIX2PTR(in);
|
|
485
|
+
return (struct backend_buffer_spec){ spec->ptr, spec->len, 1 };
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
#ifdef HAVE_RUBY_IO_BUFFER_H
|
|
@@ -493,11 +493,56 @@ struct io_buffer get_io_buffer(VALUE in, int rw) {
|
|
|
493
493
|
rb_io_buffer_get_bytes_for_reading(in, (const void **)&ptr, &len);
|
|
494
494
|
else
|
|
495
495
|
rb_io_buffer_get_bytes_for_writing(in, &ptr, &len);
|
|
496
|
-
return (struct
|
|
496
|
+
return (struct backend_buffer_spec){ ptr, len, 1 };
|
|
497
497
|
}
|
|
498
498
|
#endif
|
|
499
499
|
|
|
500
|
-
return (struct
|
|
500
|
+
return (struct backend_buffer_spec){ (unsigned char *)RSTRING_PTR(in), RSTRING_LEN(in), 0 };
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
inline void backend_prepare_read_buffer(VALUE buffer, VALUE length, struct backend_buffer_spec *buffer_spec, int pos) {
|
|
504
|
+
buffer_spec->pos = pos;
|
|
505
|
+
buffer_spec->expandable = 0;
|
|
506
|
+
buffer_spec->shrinkable = 0;
|
|
507
|
+
if (buffer_spec->raw) {
|
|
508
|
+
if (buffer_spec->pos < 0 || buffer_spec->pos > buffer_spec->len)
|
|
509
|
+
buffer_spec->pos = buffer_spec->len;
|
|
510
|
+
buffer_spec->ptr += buffer_spec->pos;
|
|
511
|
+
buffer_spec->len -= buffer_spec->pos;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
buffer_spec->expandable = length == Qnil;
|
|
515
|
+
long expected_read_length = buffer_spec->expandable ? 4096 : FIX2INT(length);
|
|
516
|
+
long string_cap = rb_str_capacity(buffer);
|
|
517
|
+
if (buffer_spec->pos < 0 || buffer_spec->pos > buffer_spec->len)
|
|
518
|
+
buffer_spec->pos = buffer_spec->len;
|
|
519
|
+
|
|
520
|
+
if (string_cap < expected_read_length + buffer_spec->pos) {
|
|
521
|
+
buffer_spec->shrinkable = io_setstrbuf(&buffer, expected_read_length + buffer_spec->pos);
|
|
522
|
+
buffer_spec->ptr = (unsigned char *)RSTRING_PTR(buffer) + buffer_spec->pos;
|
|
523
|
+
buffer_spec->len = expected_read_length;
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
buffer_spec->ptr += buffer_spec->pos;
|
|
527
|
+
buffer_spec->len = string_cap - buffer_spec->pos;
|
|
528
|
+
if (buffer_spec->len > expected_read_length)
|
|
529
|
+
buffer_spec->len = expected_read_length;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
inline void backend_grow_string_buffer(VALUE buffer, struct backend_buffer_spec *buffer_spec, int total) {
|
|
535
|
+
// resize buffer to double its capacity
|
|
536
|
+
rb_str_resize(buffer, total + buffer_spec->pos);
|
|
537
|
+
rb_str_modify_expand(buffer, rb_str_capacity(buffer));
|
|
538
|
+
buffer_spec->shrinkable = 0;
|
|
539
|
+
buffer_spec->ptr = (unsigned char *)RSTRING_PTR(buffer) + total + buffer_spec->pos;
|
|
540
|
+
buffer_spec->len = rb_str_capacity(buffer) - total - buffer_spec->pos;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
inline void backend_finalize_string_buffer(VALUE buffer, struct backend_buffer_spec *buffer_spec, int total, rb_io_t *fptr) {
|
|
544
|
+
io_set_read_length(buffer, buffer_spec->pos + total, buffer_spec->shrinkable);
|
|
545
|
+
if (fptr) io_enc_str(buffer, fptr);
|
|
501
546
|
}
|
|
502
547
|
|
|
503
548
|
VALUE coerce_io_string_or_buffer(VALUE buf) {
|
|
@@ -55,23 +55,31 @@ struct backend_stats backend_base_stats(struct Backend_base *base);
|
|
|
55
55
|
}
|
|
56
56
|
#define COND_TRACE(base, ...) if (SHOULD_TRACE(base)) { TRACE(base, __VA_ARGS__); }
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// buffers
|
|
59
59
|
|
|
60
|
-
struct
|
|
60
|
+
struct buffer_spec {
|
|
61
61
|
unsigned char *ptr;
|
|
62
62
|
int len;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
struct
|
|
65
|
+
struct backend_buffer_spec {
|
|
66
66
|
unsigned char *ptr;
|
|
67
67
|
int len;
|
|
68
68
|
int raw;
|
|
69
|
+
int pos;
|
|
70
|
+
int expandable:1;
|
|
71
|
+
int shrinkable:1;
|
|
72
|
+
int reserved:30;
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
#define FIX2PTR(v) ((void *)(FIX2LONG(v)))
|
|
72
76
|
#define PTR2FIX(p) LONG2FIX((long)p)
|
|
73
77
|
|
|
74
|
-
struct
|
|
78
|
+
struct backend_buffer_spec backend_get_buffer_spec(VALUE in, int rw);
|
|
79
|
+
void backend_prepare_read_buffer(VALUE buffer, VALUE length, struct backend_buffer_spec *buffer_spec, int pos);
|
|
80
|
+
void backend_grow_string_buffer(VALUE buffer, struct backend_buffer_spec *buffer_spec, int total);
|
|
81
|
+
void backend_finalize_string_buffer(VALUE buffer, struct backend_buffer_spec *buffer_spec, int total, rb_io_t *fptr);
|
|
82
|
+
|
|
75
83
|
VALUE coerce_io_string_or_buffer(VALUE buf);
|
|
76
84
|
|
|
77
85
|
#ifdef POLYPHONY_USE_PIDFD_OPEN
|
|
@@ -106,23 +114,23 @@ VALUE backend_snooze(struct Backend_base *backend);
|
|
|
106
114
|
|
|
107
115
|
// macros for doing read loops
|
|
108
116
|
#define READ_LOOP_PREPARE_STR() { \
|
|
109
|
-
|
|
110
|
-
shrinkable = io_setstrbuf(&
|
|
111
|
-
|
|
117
|
+
buffer = Qnil; \
|
|
118
|
+
shrinkable = io_setstrbuf(&buffer, len); \
|
|
119
|
+
ptr = RSTRING_PTR(buffer); \
|
|
112
120
|
total = 0; \
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
#define READ_LOOP_YIELD_STR() { \
|
|
116
|
-
io_set_read_length(
|
|
117
|
-
if (fptr) io_enc_str(
|
|
118
|
-
rb_yield(
|
|
124
|
+
io_set_read_length(buffer, total, shrinkable); \
|
|
125
|
+
if (fptr) io_enc_str(buffer, fptr); \
|
|
126
|
+
rb_yield(buffer); \
|
|
119
127
|
READ_LOOP_PREPARE_STR(); \
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
#define READ_LOOP_PASS_STR_TO_RECEIVER(receiver, method_id) { \
|
|
123
|
-
io_set_read_length(
|
|
124
|
-
if (fptr) io_enc_str(
|
|
125
|
-
rb_funcall_passing_block(receiver, method_id, 1, &
|
|
131
|
+
io_set_read_length(buffer, total, shrinkable); \
|
|
132
|
+
if (fptr) io_enc_str(buffer, fptr); \
|
|
133
|
+
rb_funcall_passing_block(receiver, method_id, 1, &buffer); \
|
|
126
134
|
READ_LOOP_PREPARE_STR(); \
|
|
127
135
|
}
|
|
128
136
|
|