pigeonhole-db 1.1.2 → 1.2.0
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/Cargo.lock +37 -16
- data/Cargo.toml +11 -5
- data/extconf.rb +2 -0
- data/lib/pigeonhole/api.rb +149 -13
- data/lib/pigeonhole/fiber.rb +184 -0
- data/lib/pigeonhole/memory.rb +114 -12
- data/lib/pigeonhole/version.rb +1 -1
- data/lib/pigeonhole.rb +1 -0
- data/sig/pigeonhole.rbs +30 -1
- data/src/classes.rs +44 -7
- data/src/db.rs +54 -0
- data/src/feed.rs +62 -113
- data/src/fiber.rs +394 -0
- data/src/lib.rs +123 -6
- data/src/memory.rs +304 -98
- data/src/memory_fiber.rs +400 -0
- data/src/offload.rs +217 -0
- data/src/table.rs +301 -11
- data/src/waits.rs +461 -0
- data/vendor/bundle/ruby/3.4.0/cache/async-2.46.0.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/console-1.38.0.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/fiber-annotation-0.2.0.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/fiber-local-1.1.0.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/fiber-storage-1.0.1.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/io-event-1.22.3.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/cache/json-3.1.0.gem +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/IO_Event.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/gem_make.out +45 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/mkmf.log +506 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/gem_make.out +31 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/generator.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/parser.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/mkmf.log +347 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/gem_make.out +14 -6
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/prism/prism.so +0 -0
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/rbs_extension.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/best-practices.md +209 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/debugging.md +63 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/getting-started.md +213 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/index.yaml +31 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/scheduler.md +109 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/tasks.md +453 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/context/thread-safety.md +694 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/barrier.md +41 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/barrier.rb +132 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/cancel.rb +80 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/clock.rb +95 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/condition.md +31 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/condition.rb +65 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/console.rb +42 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/deadline.rb +71 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/error.rb +17 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/fork_handler.rb +32 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/idler.rb +71 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/limited_queue.rb +13 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/list.rb +319 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/loop.rb +84 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/node.rb +347 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/notification.rb +39 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/priority_queue.rb +253 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/promise.rb +266 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/queue.rb +155 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/reactor.rb +34 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/scheduler.rb +710 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/semaphore.md +41 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/semaphore.rb +127 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/stop.rb +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/task.rb +549 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/timeout.rb +88 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/variable.rb +64 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/version.rb +9 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async/waiter.rb +61 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/async.rb +13 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/kernel/async.rb +43 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/kernel/barrier.rb +31 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/kernel/sync.rb +43 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/metrics/provider/async/task.rb +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/metrics/provider/async.rb +6 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/traces/provider/async/barrier.rb +17 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/traces/provider/async/task.rb +40 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/lib/traces/provider/async.rb +7 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/license.md +58 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/readme.md +118 -0
- data/vendor/bundle/ruby/3.4.0/gems/async-2.46.0/releases.md +488 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/bake/console.rb +18 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/command-line.md +47 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/configuration.md +23 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/events.md +71 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/getting-started.md +170 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/index.yaml +28 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/context/integration.md +37 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/adapter.rb +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/capture.rb +126 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/clock.rb +48 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/compatible/logger.rb +104 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/config.rb +96 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/event/failure.rb +108 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/event/generic.rb +47 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/event/spawn.rb +111 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/event.rb +13 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/filter.rb +235 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/format/safe.rb +283 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/format.rb +18 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/interface.rb +61 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/logger.rb +66 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/default.rb +51 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/failure.rb +42 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/null.rb +24 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/sensitive.rb +146 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/serialized.rb +102 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/split.rb +39 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/terminal.rb +310 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output/wrapper.rb +39 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/output.rb +36 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/progress.rb +168 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/resolver.rb +120 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/formatter/failure.rb +69 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/formatter/progress.rb +69 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/formatter/spawn.rb +53 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/formatter.rb +16 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/text.rb +129 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal/xterm.rb +91 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/terminal.rb +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/version.rb +8 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console/warn.rb +33 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/lib/console.rb +15 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/license.md +34 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/readme.md +122 -0
- data/vendor/bundle/ruby/3.4.0/gems/console-1.38.0/releases.md +147 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-annotation-0.2.0/lib/fiber/annotation/version.rb +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-annotation-0.2.0/lib/fiber/annotation.rb +58 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-annotation-0.2.0/license.md +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-annotation-0.2.0/readme.md +19 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-local-1.1.0/lib/fiber/local/version.rb +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-local-1.1.0/lib/fiber/local.rb +56 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-local-1.1.0/license.md +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-local-1.1.0/readme.md +82 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-storage-1.0.1/lib/fiber/storage/version.rb +12 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-storage-1.0.1/lib/fiber/storage.rb +89 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-storage-1.0.1/license.md +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-storage-1.0.1/readme.md +43 -0
- data/vendor/bundle/ruby/3.4.0/gems/fiber-storage-1.0.1/releases.md +5 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/context/futex.md +208 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/context/getting-started.md +93 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/context/index.yaml +15 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/design.md +63 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/Makefile +273 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/extconf.h +16 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/extconf.rb +88 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/array.h +175 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/event.c +41 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/event.h +24 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/fiber.c +63 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/fiber.h +23 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/futex.c +489 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/futex.h +42 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/interrupt.c +100 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/interrupt.h +30 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/list.h +107 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/epoll.c +1194 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/epoll.h +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/kqueue.c +1196 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/kqueue.h +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/pidfd.c +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/selector.c +424 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/selector.h +194 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/uring.c +2017 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/selector/uring.h +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/time.c +35 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/time.h +17 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/worker_pool.c +520 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/worker_pool.h +8 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/worker_pool_test.c +205 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/io/event/worker_pool_test.h +9 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/IO_Event.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/debug/selector.rb +219 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/interrupt.rb +49 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/native.rb +11 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/priority_heap.rb +263 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/selector/nonblock.rb +21 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/selector/select.rb +430 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/selector.rb +62 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/support.rb +16 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/timers.rb +220 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event/version.rb +12 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/io/event.rb +10 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/license.md +42 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/readme.md +101 -0
- data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/releases.md +190 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/BSDL +22 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/CHANGES.md +877 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/COPYING +56 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/LEGAL +20 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/README.md +228 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/fbuffer/fbuffer.h +263 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/generator/Makefile +273 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/generator/extconf.rb +19 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/generator/generator.c +2172 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/json.h +202 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/parser/Makefile +273 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/parser/extconf.rb +43 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/parser/parser.c +2925 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/simd/conf.rb +24 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/simd/simd.h +208 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/vendor/fast_float_parser.h +814 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/vendor/fpconv.c +480 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/vendor/jeaiii-ltoa.h +267 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/json.gemspec +62 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/common.rb +923 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/generator/state.rb +73 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/generator.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/parser.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext.rb +195 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/truffle_ruby/generator.rb +828 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/version.rb +5 -0
- data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json.rb +460 -0
- data/vendor/bundle/ruby/3.4.0/gems/prism-1.9.0/lib/prism/prism.so +0 -0
- data/vendor/bundle/ruby/3.4.0/gems/rbs-4.2.0/lib/rbs_extension.so +0 -0
- data/vendor/bundle/ruby/3.4.0/specifications/async-2.46.0.gemspec +27 -0
- data/vendor/bundle/ruby/3.4.0/specifications/console-1.38.0.gemspec +27 -0
- data/vendor/bundle/ruby/3.4.0/specifications/fiber-annotation-0.2.0.gemspec +21 -0
- data/vendor/bundle/ruby/3.4.0/specifications/fiber-local-1.1.0.gemspec +25 -0
- data/vendor/bundle/ruby/3.4.0/specifications/fiber-storage-1.0.1.gemspec +21 -0
- data/vendor/bundle/ruby/3.4.0/specifications/io-event-1.22.3.gemspec +24 -0
- data/vendor/bundle/ruby/3.4.0/specifications/json-3.1.0.gemspec +0 -0
- data/vendor/cache/Cargo.toml +2 -2
- data/vendor/cache/src/lib.rs +60 -23
- data/vendor/cache/src/s3fifo.rs +215 -44
- data/vendor/cache/src/tests.rs +2 -1
- data/vendor/compaction/Cargo.toml +6 -6
- data/vendor/engine/Cargo.toml +11 -11
- data/vendor/engine/src/clock.rs +14 -0
- data/vendor/engine/src/compact.rs +26 -14
- data/vendor/engine/src/engine/hooks.rs +88 -13
- data/vendor/engine/src/engine/info.rs +5 -2
- data/vendor/engine/src/engine.rs +1296 -30
- data/vendor/engine/src/error.rs +1 -1
- data/vendor/engine/src/feed.rs +408 -40
- data/vendor/engine/src/feed_reader.rs +1507 -274
- data/vendor/engine/src/flush.rs +45 -5
- data/vendor/engine/src/lib.rs +10 -4
- data/vendor/engine/src/maintenance.rs +620 -444
- data/vendor/engine/src/manifest.rs +157 -7
- data/vendor/engine/src/options.rs +34 -2
- data/vendor/engine/src/read/keys.rs +106 -12
- data/vendor/engine/src/read/knn.rs +35 -3
- data/vendor/engine/src/read/reduce.rs +18 -12
- data/vendor/engine/src/read/reduce_async.rs +396 -0
- data/vendor/engine/src/read/traverse.rs +12 -1
- data/vendor/engine/src/read.rs +524 -41
- data/vendor/engine/src/row_cache.rs +6 -0
- data/vendor/engine/src/shard/tablets.rs +2 -1
- data/vendor/engine/src/shard.rs +433 -27
- data/vendor/engine/src/snapshot.rs +26 -0
- data/vendor/engine/src/source.rs +10 -0
- data/vendor/engine/src/watermark_waiters.rs +92 -3
- data/vendor/engine/src/write.rs +130 -3
- data/vendor/format/Cargo.toml +1 -1
- data/vendor/format/src/block.rs +7 -0
- data/vendor/format/src/feed.rs +138 -8
- data/vendor/format/src/manifest.rs +27 -0
- data/vendor/format/src/shm.rs +5 -0
- data/vendor/format/src/superblock.rs +3 -2
- data/vendor/format/src/version.rs +5 -2
- data/vendor/format/src/wal.rs +22 -1
- data/vendor/io/Cargo.toml +2 -2
- data/vendor/io/src/async_poll.rs +19 -0
- data/vendor/io/src/lib.rs +3 -1
- data/vendor/io/src/os/unix.rs +30 -0
- data/vendor/io/src/os/windows.rs +18 -0
- data/vendor/io/src/pread.rs +4 -0
- data/vendor/io/src/sim.rs +81 -15
- data/vendor/io/src/sys.rs +9 -0
- data/vendor/io/src/uring.rs +4 -0
- data/vendor/io/src/vfs.rs +10 -0
- data/vendor/memory/Cargo.toml +11 -5
- data/vendor/memory/README.md +1 -1
- data/vendor/memory/src/consolidate.rs +68 -58
- data/vendor/memory/src/feed_loop.rs +113 -58
- data/vendor/memory/src/forget.rs +63 -37
- data/vendor/memory/src/hooks.rs +19 -0
- data/vendor/memory/src/ivf.rs +70 -26
- data/vendor/memory/src/lib.rs +2 -2
- data/vendor/memory/src/recall.rs +865 -231
- data/vendor/memory/src/store.rs +405 -135
- data/vendor/memtable/Cargo.toml +3 -3
- data/vendor/memtable/src/lib.rs +29 -3
- data/vendor/memtable/src/tests.rs +35 -0
- data/vendor/pager/Cargo.toml +3 -3
- data/vendor/pager/src/lib.rs +56 -0
- data/vendor/pigeonhole/Cargo.toml +7 -5
- data/vendor/pigeonhole/README.md +1 -1
- data/vendor/pigeonhole/src/cell.rs +233 -2
- data/vendor/pigeonhole/src/db.rs +224 -8
- data/vendor/pigeonhole/src/feed.rs +573 -98
- data/vendor/pigeonhole/src/files.rs +270 -0
- data/vendor/pigeonhole/src/info.rs +7 -2
- data/vendor/pigeonhole/src/lib.rs +14 -3
- data/vendor/pigeonhole/src/metrics.rs +246 -1
- data/vendor/pigeonhole/src/nonblocking.rs +160 -94
- data/vendor/pigeonhole/src/options.rs +197 -21
- data/vendor/pigeonhole/src/read/budget.rs +178 -51
- data/vendor/pigeonhole/src/read.rs +468 -19
- data/vendor/pigeonhole/src/recovery.rs +9 -3
- data/vendor/pigeonhole/src/replication.rs +648 -0
- data/vendor/pigeonhole/src/table.rs +17 -1
- data/vendor/pigeonhole/src/write.rs +612 -26
- data/vendor/runtime/Cargo.toml +2 -2
- data/vendor/runtime/src/cell.rs +832 -0
- data/vendor/runtime/src/drivers.rs +210 -69
- data/vendor/runtime/src/lib.rs +327 -27
- data/vendor/runtime/src/pool.rs +3 -1
- data/vendor/runtime/src/sched.rs +5 -1
- data/vendor/runtime/src/signal.rs +8 -0
- data/vendor/shm/Cargo.toml +3 -3
- data/vendor/shm/src/lib.rs +1 -1
- data/vendor/shm/src/lock.rs +15 -0
- data/vendor/shm/src/region.rs +218 -160
- data/vendor/sst/Cargo.toml +4 -4
- data/vendor/sst/src/blob.rs +1 -0
- data/vendor/sst/src/iter.rs +14 -0
- data/vendor/sst/src/lib.rs +1 -0
- data/vendor/sst/src/reader.rs +34 -31
- data/vendor/text/Cargo.toml +9 -2
- data/vendor/text/src/fuzzy.rs +178 -57
- data/vendor/text/src/index.rs +84 -19
- data/vendor/text/src/maxscore.rs +964 -145
- data/vendor/text/src/query.rs +14 -0
- data/vendor/text/src/search.rs +413 -84
- data/vendor/vector/Cargo.toml +2 -2
- data/vendor/vector/src/hooks.rs +8 -0
- data/vendor/vector/src/index.rs +59 -10
- data/vendor/wal/Cargo.toml +3 -3
- data/vendor/wal/src/recovery.rs +17 -29
- data/vendor/wal/src/stream.rs +137 -120
- metadata +213 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2021, by Wander Hillen.
|
|
5
|
+
# Copyright, 2021-2026, by Samuel Williams.
|
|
6
|
+
|
|
7
|
+
class IO
|
|
8
|
+
module Event
|
|
9
|
+
# A priority queue implementation using a standard binary minheap. It uses straight comparison
|
|
10
|
+
# of its contents to determine priority.
|
|
11
|
+
# See <https://en.wikipedia.org/wiki/Binary_heap> for explanations of the main methods.
|
|
12
|
+
class PriorityHeap
|
|
13
|
+
HEAPIFY_INSERT_RATIO = 2
|
|
14
|
+
|
|
15
|
+
# Initializes the heap.
|
|
16
|
+
def initialize
|
|
17
|
+
# The heap is represented with an array containing a binary tree. See
|
|
18
|
+
# https://en.wikipedia.org/wiki/Binary_heap#Heap_implementation for how this array
|
|
19
|
+
# is built up.
|
|
20
|
+
@contents = []
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @returns [Object | Nil] the smallest element in the heap without removing it, or nil if the heap is empty.
|
|
24
|
+
def peek
|
|
25
|
+
@contents[0]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @returns [Integer] the number of elements in the heap.
|
|
29
|
+
def size
|
|
30
|
+
@contents.size
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @returns [Boolean] true if the heap is empty, false otherwise.
|
|
34
|
+
def empty?
|
|
35
|
+
@contents.empty?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Removes and returns the smallest element in the heap, or nil if the heap is empty.
|
|
39
|
+
#
|
|
40
|
+
# @returns [Object | Nil] The smallest element in the heap, or nil if the heap is empty.
|
|
41
|
+
def pop
|
|
42
|
+
# If the heap is empty:
|
|
43
|
+
if @contents.empty?
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# If we have only one item, no swapping is required:
|
|
48
|
+
if @contents.size == 1
|
|
49
|
+
return @contents.pop
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Take the root of the tree:
|
|
53
|
+
value = @contents[0]
|
|
54
|
+
|
|
55
|
+
# Remove the last item in the tree:
|
|
56
|
+
last = @contents.pop
|
|
57
|
+
|
|
58
|
+
# Overwrite the root of the tree with the item:
|
|
59
|
+
@contents[0] = last
|
|
60
|
+
|
|
61
|
+
# Bubble it down into place:
|
|
62
|
+
bubble_down(0)
|
|
63
|
+
|
|
64
|
+
# validate!
|
|
65
|
+
|
|
66
|
+
return value
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Add a new element to the heap, then rearrange elements until the heap invariant is true again.
|
|
70
|
+
#
|
|
71
|
+
# @parameter element [Object] The element to add to the heap.
|
|
72
|
+
def push(element)
|
|
73
|
+
# Insert the item at the end of the heap:
|
|
74
|
+
@contents.push(element)
|
|
75
|
+
|
|
76
|
+
# Bubble it up into position:
|
|
77
|
+
bubble_up(@contents.size - 1)
|
|
78
|
+
|
|
79
|
+
# validate!
|
|
80
|
+
|
|
81
|
+
return self
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Add multiple elements to the heap efficiently.
|
|
85
|
+
#
|
|
86
|
+
# @parameter elements [Array] The elements to add to the heap.
|
|
87
|
+
# @returns [self] Returns self for method chaining.
|
|
88
|
+
def concat(elements)
|
|
89
|
+
return self if elements.empty?
|
|
90
|
+
|
|
91
|
+
# Rebuilding the whole heap is `O(n + m)`, where `n` is the existing heap size and `m` is the appended batch size. Incremental `push` is `O(m log(n))`, but is often closer to `O(m)` when appended elements are later than the existing entries and do not bubble far. Prefer `heapify` only when building from empty or when the batch dominates the existing heap.
|
|
92
|
+
if @contents.empty? || elements.size > @contents.size * HEAPIFY_INSERT_RATIO
|
|
93
|
+
@contents.concat(elements)
|
|
94
|
+
heapify!
|
|
95
|
+
else
|
|
96
|
+
elements.each{|element| push(element)}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
return self
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Mutate the heap contents directly, then rebuild the heap property.
|
|
103
|
+
#
|
|
104
|
+
# This supports batched operations that can be completed with a single `O(n)` heapify instead of multiple `O(log n)` heap operations.
|
|
105
|
+
#
|
|
106
|
+
# @yields {|contents| ...} The heap contents array.
|
|
107
|
+
# @returns [self] Returns self for method chaining.
|
|
108
|
+
def heapify
|
|
109
|
+
yield @contents
|
|
110
|
+
|
|
111
|
+
# The block may arbitrarily append, delete or reorder contents, so repair the invariant with one `O(n)` bottom-up heapify pass.
|
|
112
|
+
heapify!
|
|
113
|
+
|
|
114
|
+
return self
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Empties out the heap, discarding all elements
|
|
118
|
+
def clear!
|
|
119
|
+
@contents = []
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Remove a specific element from the heap.
|
|
123
|
+
#
|
|
124
|
+
# O(n) where n is the number of elements in the heap.
|
|
125
|
+
#
|
|
126
|
+
# @parameter element [Object] The element to remove.
|
|
127
|
+
# @returns [Object | Nil] The removed element, or nil if not found.
|
|
128
|
+
def delete(element)
|
|
129
|
+
# Find the index of the element - O(n) linear search
|
|
130
|
+
index = @contents.index(element)
|
|
131
|
+
return nil unless index
|
|
132
|
+
|
|
133
|
+
# If it's the last element, just remove it
|
|
134
|
+
if index == @contents.size - 1
|
|
135
|
+
return @contents.pop
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Store the value we're removing
|
|
139
|
+
removed_value = @contents[index]
|
|
140
|
+
|
|
141
|
+
# Replace with the last element
|
|
142
|
+
last = @contents.pop
|
|
143
|
+
@contents[index] = last
|
|
144
|
+
|
|
145
|
+
# Restore heap property - might need to bubble up or down
|
|
146
|
+
if index > 0 && @contents[index] < @contents[(index - 1) / 2]
|
|
147
|
+
# New element is smaller than parent, bubble up
|
|
148
|
+
bubble_up(index)
|
|
149
|
+
else
|
|
150
|
+
# New element might be larger than children, bubble down
|
|
151
|
+
bubble_down(index)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# validate!
|
|
155
|
+
|
|
156
|
+
return removed_value
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Remove elements matching the given block condition by rebuilding the heap.
|
|
160
|
+
#
|
|
161
|
+
# This is more efficient than multiple delete operations when removing many elements.
|
|
162
|
+
#
|
|
163
|
+
# O(n) where n is the number of elements in the heap.
|
|
164
|
+
#
|
|
165
|
+
# @yields [Object] Each element in the heap for testing
|
|
166
|
+
# @returns [Integer] The number of elements removed
|
|
167
|
+
def delete_if
|
|
168
|
+
return enum_for(:delete_if) unless block_given?
|
|
169
|
+
|
|
170
|
+
original_size = @contents.size
|
|
171
|
+
|
|
172
|
+
# Filter out elements that match the condition - O(n)
|
|
173
|
+
@contents.reject!{|element| yield(element)}
|
|
174
|
+
|
|
175
|
+
# If we removed elements, rebuild the heap - O(n)
|
|
176
|
+
if @contents.size < original_size
|
|
177
|
+
heapify!
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Return number of elements removed
|
|
181
|
+
original_size - @contents.size
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Validate the heap invariant. Every element except the root must not be smaller than its parent element. Note that it MAY be equal.
|
|
185
|
+
def valid?
|
|
186
|
+
# Notice we skip index 0 on purpose, because it has no parent:
|
|
187
|
+
(1..(@contents.size - 1)).all?{|index| @contents[index] >= @contents[(index - 1) / 2]}
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
private
|
|
191
|
+
|
|
192
|
+
# Rebuild the heap property from an arbitrary array in O(n) time.
|
|
193
|
+
# Uses bottom-up heapify algorithm starting from the last non-leaf node.
|
|
194
|
+
def heapify!
|
|
195
|
+
return if @contents.size <= 1
|
|
196
|
+
|
|
197
|
+
# Start from the last non-leaf node and work backwards to root:
|
|
198
|
+
last_non_leaf_index = (@contents.size / 2) - 1
|
|
199
|
+
last_non_leaf_index.downto(0) do |index|
|
|
200
|
+
bubble_down(index)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# validate!
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Left here for reference, but unused.
|
|
207
|
+
# def swap(i, j)
|
|
208
|
+
# @contents[i], @contents[j] = @contents[j], @contents[i]
|
|
209
|
+
# end
|
|
210
|
+
|
|
211
|
+
def bubble_up(index)
|
|
212
|
+
parent_index = (index - 1) / 2 # watch out, integer division!
|
|
213
|
+
|
|
214
|
+
while index > 0 && @contents[index] < @contents[parent_index]
|
|
215
|
+
# If the node has a smaller value than its parent, swap these nodes to uphold the minheap invariant and update the index of the 'current' node. If the node is already at index 0, we can also stop because that is the root of the heap.
|
|
216
|
+
# swap(index, parent_index)
|
|
217
|
+
@contents[index], @contents[parent_index] = @contents[parent_index], @contents[index]
|
|
218
|
+
|
|
219
|
+
index = parent_index
|
|
220
|
+
parent_index = (index - 1) / 2 # watch out, integer division!
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def bubble_down(index)
|
|
225
|
+
swap_value = 0
|
|
226
|
+
swap_index = nil
|
|
227
|
+
|
|
228
|
+
while true
|
|
229
|
+
left_index = (2 * index) + 1
|
|
230
|
+
left_value = @contents[left_index]
|
|
231
|
+
|
|
232
|
+
if left_value.nil?
|
|
233
|
+
# This node has no children so it can't bubble down any further. We're done here!
|
|
234
|
+
return
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Determine which of the child nodes has the smallest value:
|
|
238
|
+
right_index = left_index + 1
|
|
239
|
+
right_value = @contents[right_index]
|
|
240
|
+
|
|
241
|
+
if right_value.nil? or right_value > left_value
|
|
242
|
+
swap_value = left_value
|
|
243
|
+
swap_index = left_index
|
|
244
|
+
else
|
|
245
|
+
swap_value = right_value
|
|
246
|
+
swap_index = right_index
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
if @contents[index] < swap_value
|
|
250
|
+
# No need to swap, the minheap invariant is already satisfied:
|
|
251
|
+
return
|
|
252
|
+
else
|
|
253
|
+
# At least one of the child node has a smaller value than the current node, swap current node with that child and update current node for if it might need to bubble down even further:
|
|
254
|
+
# swap(index, swap_index)
|
|
255
|
+
@contents[index], @contents[swap_index] = @contents[swap_index], @contents[index]
|
|
256
|
+
|
|
257
|
+
index = swap_index
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2022-2024, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require "io/nonblock"
|
|
7
|
+
|
|
8
|
+
module IO::Event
|
|
9
|
+
module Selector
|
|
10
|
+
# Execute the given block in non-blocking mode.
|
|
11
|
+
#
|
|
12
|
+
# @parameter io [IO] The IO object to operate on.
|
|
13
|
+
# @yields {...} The block to execute.
|
|
14
|
+
def self.nonblock(io, &block)
|
|
15
|
+
io.nonblock(&block)
|
|
16
|
+
rescue Errno::EBADF
|
|
17
|
+
# Windows.
|
|
18
|
+
yield
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2021-2026, by Samuel Williams.
|
|
5
|
+
# Copyright, 2023, by Math Ieu.
|
|
6
|
+
|
|
7
|
+
require_relative "../interrupt"
|
|
8
|
+
|
|
9
|
+
module IO::Event
|
|
10
|
+
module Selector
|
|
11
|
+
# A pure-Ruby implementation of the event selector.
|
|
12
|
+
class Select
|
|
13
|
+
# Initialize the selector with the given event loop fiber.
|
|
14
|
+
def initialize(loop)
|
|
15
|
+
@loop = loop
|
|
16
|
+
@owner = Process.pid
|
|
17
|
+
|
|
18
|
+
@waiting = Hash.new.compare_by_identity
|
|
19
|
+
|
|
20
|
+
# Flag indicating whether the selector is currently blocked in a system call.
|
|
21
|
+
# Set to true when blocked in ::IO.select, false otherwise.
|
|
22
|
+
# Used by wakeup() to determine if an interrupt signal is needed.
|
|
23
|
+
@blocked = false
|
|
24
|
+
|
|
25
|
+
@ready = Queue.new
|
|
26
|
+
@interrupt = Interrupt.attach(self)
|
|
27
|
+
|
|
28
|
+
@idle_duration = 0.0
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @attribute [Fiber] The event loop fiber.
|
|
32
|
+
attr :loop
|
|
33
|
+
|
|
34
|
+
# @attribute [Float] This is the amount of time the event loop was idle during the last select call.
|
|
35
|
+
attr :idle_duration
|
|
36
|
+
|
|
37
|
+
# Wake up the event loop if it is currently sleeping.
|
|
38
|
+
def wakeup
|
|
39
|
+
if @blocked
|
|
40
|
+
@interrupt.signal
|
|
41
|
+
|
|
42
|
+
return true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
return false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Close the selector and release any resources.
|
|
49
|
+
def close
|
|
50
|
+
@interrupt.close
|
|
51
|
+
|
|
52
|
+
@loop = nil
|
|
53
|
+
@waiting = nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @returns [Boolean] Whether the selector is closed or belongs to a different process.
|
|
57
|
+
def closed?
|
|
58
|
+
@loop.nil? || @owner != Process.pid
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# An optional reference to a fiber which can be cleared before it is resumed.
|
|
62
|
+
Optional = Struct.new(:fiber) do
|
|
63
|
+
# Transfer control to the fiber if it is still available.
|
|
64
|
+
def transfer(*arguments)
|
|
65
|
+
fiber&.transfer(*arguments)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @returns [Boolean | Nil] Whether the referenced fiber is still alive.
|
|
69
|
+
def alive?
|
|
70
|
+
fiber&.alive?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Clear the referenced fiber.
|
|
74
|
+
def nullify
|
|
75
|
+
self.fiber = nil
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Transfer from the current fiber to the event loop.
|
|
80
|
+
def transfer
|
|
81
|
+
@loop.transfer
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Transfer from the current fiber to the specified fiber. Put the current fiber into the ready list.
|
|
85
|
+
def resume(fiber, *arguments)
|
|
86
|
+
optional = Optional.new(Fiber.current)
|
|
87
|
+
@ready.push(optional)
|
|
88
|
+
|
|
89
|
+
fiber.transfer(*arguments)
|
|
90
|
+
ensure
|
|
91
|
+
optional.nullify
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Yield from the current fiber back to the event loop. Put the current fiber into the ready list.
|
|
95
|
+
def yield
|
|
96
|
+
optional = Optional.new(Fiber.current)
|
|
97
|
+
@ready.push(optional)
|
|
98
|
+
|
|
99
|
+
@loop.transfer
|
|
100
|
+
ensure
|
|
101
|
+
optional.nullify
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Append the given fiber into the ready list.
|
|
105
|
+
def push(fiber)
|
|
106
|
+
@ready.push(fiber)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Transfer to the given fiber and raise an exception. Put the current fiber into the ready list.
|
|
110
|
+
def raise(fiber, *arguments, **options)
|
|
111
|
+
optional = Optional.new(Fiber.current)
|
|
112
|
+
@ready.push(optional)
|
|
113
|
+
|
|
114
|
+
fiber.raise(*arguments, **options)
|
|
115
|
+
ensure
|
|
116
|
+
optional.nullify
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# @returns [Boolean] Whether the ready list is not empty, i.e. there are fibers ready to be resumed.
|
|
120
|
+
def ready?
|
|
121
|
+
!@ready.empty?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# A linked list node used to track fibers waiting for IO events.
|
|
125
|
+
Waiter = Struct.new(:fiber, :events, :tail) do
|
|
126
|
+
# @returns [Boolean | Nil] Whether the waiting fiber is still alive.
|
|
127
|
+
def alive?
|
|
128
|
+
self.fiber&.alive?
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Dispatch the given events to the list of waiting fibers. If the fiber was not waiting for the given events, it is reactivated by calling the given block.
|
|
132
|
+
def dispatch(events, &reactivate)
|
|
133
|
+
# We capture the tail here, because calling reactivate might modify it:
|
|
134
|
+
tail = self.tail
|
|
135
|
+
|
|
136
|
+
if fiber = self.fiber
|
|
137
|
+
if fiber.alive?
|
|
138
|
+
revents = events & self.events
|
|
139
|
+
if revents.zero?
|
|
140
|
+
reactivate.call(self)
|
|
141
|
+
else
|
|
142
|
+
self.fiber = nil
|
|
143
|
+
fiber.transfer(revents)
|
|
144
|
+
end
|
|
145
|
+
else
|
|
146
|
+
self.fiber = nil
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
tail&.dispatch(events, &reactivate)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Clear the waiting fiber so it will not be resumed.
|
|
154
|
+
def invalidate
|
|
155
|
+
self.fiber = nil
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Iterate over each active waiting fiber and its requested events.
|
|
159
|
+
def each(&block)
|
|
160
|
+
if fiber = self.fiber
|
|
161
|
+
yield fiber, self.events
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
self.tail&.each(&block)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Wait for the given IO to become readable or writable.
|
|
169
|
+
#
|
|
170
|
+
# @parameter fiber [Fiber] The fiber that is waiting.
|
|
171
|
+
# @parameter io [IO] The IO object to wait on.
|
|
172
|
+
# @parameter events [Integer] The events to wait for.
|
|
173
|
+
def io_wait(fiber, io, events)
|
|
174
|
+
waiter = @waiting[io] = Waiter.new(fiber, events, @waiting[io])
|
|
175
|
+
|
|
176
|
+
@loop.transfer || false
|
|
177
|
+
ensure
|
|
178
|
+
waiter&.invalidate
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Wait for multiple IO objects to become readable or writable.
|
|
182
|
+
#
|
|
183
|
+
# @parameter readable [Array(IO)] The list of IO objects to wait for readability.
|
|
184
|
+
# @parameter writable [Array(IO)] The list of IO objects to wait for writability.
|
|
185
|
+
# @parameter priority [Array(IO)] The list of IO objects to wait for priority events.
|
|
186
|
+
def io_select(readable, writable, priority, timeout)
|
|
187
|
+
Thread.new do
|
|
188
|
+
IO.select(readable, writable, priority, timeout)
|
|
189
|
+
end.value
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
EAGAIN = -Errno::EAGAIN::Errno
|
|
193
|
+
EWOULDBLOCK = -Errno::EWOULDBLOCK::Errno
|
|
194
|
+
|
|
195
|
+
# Whether the given error code indicates that the operation should be retried.
|
|
196
|
+
protected def again?(errno)
|
|
197
|
+
errno == EAGAIN or errno == EWOULDBLOCK
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
if defined?(IO::Buffer::VERSION) && IO::Buffer::VERSION >= 3
|
|
201
|
+
# Read at most `length` bytes from the given IO to the buffer in one operation.
|
|
202
|
+
#
|
|
203
|
+
# @parameter offset [Integer] The offset into the buffer to read to.
|
|
204
|
+
# @parameter length [Integer] The maximum number of bytes to read.
|
|
205
|
+
def io_read(fiber, io, buffer, offset, length)
|
|
206
|
+
if offset > buffer.size || length > buffer.size - offset
|
|
207
|
+
return -Errno::EINVAL::Errno
|
|
208
|
+
elsif length == 0
|
|
209
|
+
return 0
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
Selector.nonblock(io) do
|
|
213
|
+
return Fiber.blocking{buffer.read(io, offset, length)}
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Write at most `length` bytes to the given IO from the buffer in one operation.
|
|
218
|
+
#
|
|
219
|
+
# @parameter offset [Integer] The offset into the buffer to write from.
|
|
220
|
+
# @parameter length [Integer] The maximum number of bytes to write.
|
|
221
|
+
def io_write(fiber, io, buffer, offset, length)
|
|
222
|
+
if offset > buffer.size || length > buffer.size - offset
|
|
223
|
+
return -Errno::EINVAL::Errno
|
|
224
|
+
elsif length == 0
|
|
225
|
+
return 0
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
Selector.nonblock(io) do
|
|
229
|
+
return Fiber.blocking{buffer.write(io, offset, length)}
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
else
|
|
233
|
+
# Read from the given IO to the buffer.
|
|
234
|
+
#
|
|
235
|
+
# @parameter length [Integer] The minimum number of bytes to read.
|
|
236
|
+
# @parameter offset [Integer] The offset into the buffer to read to.
|
|
237
|
+
def io_read(fiber, io, buffer, length, offset = 0)
|
|
238
|
+
# Ensure offset is within the bounds of the buffer to avoid `ArgumentError`:
|
|
239
|
+
if offset > buffer.size
|
|
240
|
+
return -Errno::EINVAL::Errno
|
|
241
|
+
elsif offset == buffer.size
|
|
242
|
+
return 0
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
total = 0
|
|
246
|
+
|
|
247
|
+
Selector.nonblock(io) do
|
|
248
|
+
while true
|
|
249
|
+
result = Fiber.blocking{buffer.read(io, 0, offset)}
|
|
250
|
+
|
|
251
|
+
if result < 0
|
|
252
|
+
if length > 0 and again?(result)
|
|
253
|
+
self.io_wait(fiber, io, IO::READABLE)
|
|
254
|
+
else
|
|
255
|
+
return result
|
|
256
|
+
end
|
|
257
|
+
elsif result == 0
|
|
258
|
+
break
|
|
259
|
+
else
|
|
260
|
+
total += result
|
|
261
|
+
break if total >= length
|
|
262
|
+
offset += result
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
return total
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Write to the given IO from the buffer.
|
|
271
|
+
#
|
|
272
|
+
# @parameter length [Integer] The minimum number of bytes to write.
|
|
273
|
+
# @parameter offset [Integer] The offset into the buffer to write from.
|
|
274
|
+
def io_write(fiber, io, buffer, length, offset = 0)
|
|
275
|
+
# Ensure offset is within the bounds of the buffer to avoid `ArgumentError`:
|
|
276
|
+
if offset > buffer.size
|
|
277
|
+
return -Errno::EINVAL::Errno
|
|
278
|
+
elsif offset == buffer.size
|
|
279
|
+
return 0
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
total = 0
|
|
283
|
+
|
|
284
|
+
Selector.nonblock(io) do
|
|
285
|
+
while true
|
|
286
|
+
result = Fiber.blocking{buffer.write(io, 0, offset)}
|
|
287
|
+
|
|
288
|
+
if result < 0
|
|
289
|
+
if length > 0 and again?(result)
|
|
290
|
+
self.io_wait(fiber, io, IO::WRITABLE)
|
|
291
|
+
else
|
|
292
|
+
return result
|
|
293
|
+
end
|
|
294
|
+
elsif result == 0
|
|
295
|
+
break result
|
|
296
|
+
else
|
|
297
|
+
total += result
|
|
298
|
+
break if total >= length
|
|
299
|
+
offset += result
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
return total
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Wait for a process to change state.
|
|
309
|
+
#
|
|
310
|
+
# @parameter fiber [Fiber] The fiber to resume after waiting.
|
|
311
|
+
# @parameter pid [Integer] The process ID to wait for.
|
|
312
|
+
# @parameter flags [Integer] Flags to pass to Process::Status.wait.
|
|
313
|
+
# @returns [Process::Status] The status of the waited process.
|
|
314
|
+
def process_wait(fiber, pid, flags)
|
|
315
|
+
Selector.process_wait(pid, flags)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
private def pop_ready
|
|
319
|
+
unless @ready.empty?
|
|
320
|
+
count = @ready.size
|
|
321
|
+
|
|
322
|
+
count.times do
|
|
323
|
+
fiber = @ready.pop
|
|
324
|
+
fiber.transfer if fiber.alive?
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
return true
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Wait for IO events or a timeout.
|
|
332
|
+
#
|
|
333
|
+
# @parameter duration [Numeric | Nil] The maximum time to wait, or nil for no timeout.
|
|
334
|
+
# @returns [Integer] The number of ready IO objects.
|
|
335
|
+
def select(duration = nil)
|
|
336
|
+
if pop_ready
|
|
337
|
+
# If we have popped items from the ready list, they may influence the duration calculation, so we don't delay the event loop:
|
|
338
|
+
duration = 0
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
readable = Array.new
|
|
342
|
+
writable = Array.new
|
|
343
|
+
priority = Array.new
|
|
344
|
+
|
|
345
|
+
@waiting.delete_if do |io, waiter|
|
|
346
|
+
if io.closed?
|
|
347
|
+
# When an IO is closed, we silently drop it. Ruby 4's `rb_thread_io_close_interrupt` will take care of interrupting any fibers waiting on the closed IO, so we don't need to do anything here.
|
|
348
|
+
true
|
|
349
|
+
else
|
|
350
|
+
waiter.each do |fiber, events|
|
|
351
|
+
if (events & IO::READABLE) > 0
|
|
352
|
+
readable << io
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
if (events & IO::WRITABLE) > 0
|
|
356
|
+
writable << io
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
if (events & IO::PRIORITY) > 0
|
|
360
|
+
priority << io
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
false
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
duration = 0 unless @ready.empty?
|
|
369
|
+
error = nil
|
|
370
|
+
|
|
371
|
+
if duration&.>(0)
|
|
372
|
+
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
373
|
+
else
|
|
374
|
+
@idle_duration = 0.0
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# We need to handle interrupts on blocking IO. Every other implementation uses EINTR, but that doesn't work with `::IO.select` as it will retry the call on EINTR.
|
|
378
|
+
Thread.handle_interrupt(::Exception => :on_blocking) do
|
|
379
|
+
@blocked = true
|
|
380
|
+
readable, writable, priority = ::IO.select(readable, writable, priority, duration)
|
|
381
|
+
rescue ::Exception => error
|
|
382
|
+
# Requeue below...
|
|
383
|
+
ensure
|
|
384
|
+
@blocked = false
|
|
385
|
+
if start_time
|
|
386
|
+
end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
387
|
+
@idle_duration = end_time - start_time
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
if error
|
|
392
|
+
if error.is_a?(IOError) || error.is_a?(Errno::EBADF)
|
|
393
|
+
# This can happen if an IO is closed while we're blocked in ::IO.select. Ruby 4's `rb_thread_io_close_interrupt` will take care of interrupting any fibers waiting on the closed IO, so we don't need to do anything here, except try again:
|
|
394
|
+
return 0
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
# For all other errors (e.g. thread interrupts), re-queue on the scheduler thread:
|
|
398
|
+
Thread.current.raise(error)
|
|
399
|
+
return 0
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
ready = Hash.new(0).compare_by_identity
|
|
403
|
+
|
|
404
|
+
readable&.each do |io|
|
|
405
|
+
# Skip any IO that was closed/reused after IO.select returned - its fd number
|
|
406
|
+
# may now belong to a different file, so resuming the waiter would be wrong:
|
|
407
|
+
ready[io] |= IO::READABLE unless io.closed?
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
writable&.each do |io|
|
|
411
|
+
ready[io] |= IO::WRITABLE unless io.closed?
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
priority&.each do |io|
|
|
415
|
+
ready[io] |= IO::PRIORITY unless io.closed?
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
ready.each do |io, events|
|
|
419
|
+
@waiting.delete(io).dispatch(events) do |waiter|
|
|
420
|
+
# Re-schedule the waiting IO:
|
|
421
|
+
waiter.tail = @waiting[io]
|
|
422
|
+
@waiting[io] = waiter
|
|
423
|
+
end
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
return ready.size
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
end
|