itsi 0.1.11 → 0.1.12
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 +1535 -45
- data/{sandbox/itsi_itsi_file/Itsi.rb → Itsi.rb} +19 -13
- data/Rakefile +8 -7
- data/crates/itsi_error/src/lib.rs +9 -0
- data/crates/itsi_rb_helpers/Cargo.toml +1 -0
- data/crates/itsi_rb_helpers/src/heap_value.rs +18 -0
- data/crates/itsi_rb_helpers/src/lib.rs +34 -7
- data/crates/itsi_server/Cargo.toml +69 -30
- data/crates/itsi_server/src/lib.rs +79 -147
- data/crates/itsi_server/src/{body_proxy → ruby_types/itsi_body_proxy}/big_bytes.rs +10 -5
- data/crates/itsi_server/src/{body_proxy/itsi_body_proxy.rs → ruby_types/itsi_body_proxy/mod.rs} +22 -3
- data/crates/itsi_server/src/ruby_types/itsi_grpc_request.rs +147 -0
- data/crates/itsi_server/src/ruby_types/itsi_grpc_response.rs +19 -0
- data/crates/itsi_server/src/ruby_types/itsi_grpc_stream/mod.rs +216 -0
- data/{gems/server/ext/itsi_server/src/request/itsi_request.rs → crates/itsi_server/src/ruby_types/itsi_http_request.rs} +101 -117
- data/crates/itsi_server/src/{response/itsi_response.rs → ruby_types/itsi_http_response.rs} +72 -41
- data/crates/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +225 -0
- data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +355 -0
- data/crates/itsi_server/src/ruby_types/itsi_server.rs +82 -0
- data/crates/itsi_server/src/ruby_types/mod.rs +55 -0
- data/crates/itsi_server/src/server/bind.rs +13 -5
- data/crates/itsi_server/src/server/byte_frame.rs +32 -0
- data/crates/itsi_server/src/server/cache_store.rs +74 -0
- data/crates/itsi_server/src/server/itsi_service.rs +172 -0
- data/crates/itsi_server/src/server/lifecycle_event.rs +3 -0
- data/crates/itsi_server/src/server/listener.rs +102 -2
- data/crates/itsi_server/src/server/middleware_stack/middleware.rs +153 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/allow_list.rs +47 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_api_key.rs +58 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_basic.rs +82 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_jwt.rs +321 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/cache_control.rs +139 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/compression.rs +300 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/cors.rs +287 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/deny_list.rs +48 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/error_response.rs +127 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/etag.rs +191 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/grpc_service.rs +72 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/header_interpretation.rs +85 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/intrusion_protection.rs +195 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/log_requests.rs +82 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/mod.rs +82 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +216 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/rate_limit.rs +124 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +76 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/request_headers.rs +43 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/response_headers.rs +34 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +93 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs +162 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/string_rewrite.rs +158 -0
- data/crates/itsi_server/src/server/middleware_stack/middlewares/token_source.rs +12 -0
- data/crates/itsi_server/src/server/middleware_stack/mod.rs +315 -0
- data/crates/itsi_server/src/server/mod.rs +8 -1
- data/crates/itsi_server/src/server/process_worker.rs +38 -12
- data/crates/itsi_server/src/server/rate_limiter.rs +565 -0
- data/crates/itsi_server/src/server/request_job.rs +11 -0
- data/crates/itsi_server/src/server/serve_strategy/cluster_mode.rs +119 -42
- data/crates/itsi_server/src/server/serve_strategy/mod.rs +9 -6
- data/crates/itsi_server/src/server/serve_strategy/single_mode.rs +256 -111
- data/crates/itsi_server/src/server/signal.rs +19 -0
- data/crates/itsi_server/src/server/static_file_server.rs +984 -0
- data/crates/itsi_server/src/server/thread_worker.rs +139 -94
- data/crates/itsi_server/src/server/types.rs +43 -0
- data/crates/itsi_server/test.md +14 -0
- data/crates/itsi_tracing/Cargo.toml +1 -0
- data/crates/itsi_tracing/src/lib.rs +216 -45
- data/docs/.gitignore +7 -0
- data/docs/.gitpod.yml +15 -0
- data/docs/Itsi.rb +17 -0
- data/docs/content/_index.md +17 -0
- data/docs/content/about.md +6 -0
- data/docs/content/docs/_index.md +18 -0
- data/docs/content/docs/first-page.md +9 -0
- data/docs/content/docs/folder/_index.md +10 -0
- data/docs/content/docs/folder/leaf.md +7 -0
- data/docs/go.mod +5 -0
- data/docs/go.sum +2 -0
- data/docs/hugo.yaml +77 -0
- data/examples/static_assets_example.rb +83 -0
- data/gems/_index.md +18 -0
- data/gems/scheduler/CODE_OF_CONDUCT.md +7 -0
- data/gems/scheduler/Cargo.lock +75 -14
- data/gems/scheduler/README.md +5 -0
- data/gems/scheduler/_index.md +7 -0
- data/gems/scheduler/itsi-scheduler.gemspec +4 -1
- data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
- data/gems/scheduler/lib/itsi/scheduler.rb +2 -2
- data/gems/scheduler/test/test_file_io.rb +0 -1
- data/gems/scheduler/test/test_itsi_scheduler.rb +1 -1
- data/gems/server/CHANGELOG.md +5 -0
- data/gems/server/CODE_OF_CONDUCT.md +7 -0
- data/gems/server/Cargo.lock +1536 -45
- data/gems/server/README.md +4 -0
- data/gems/server/_index.md +6 -0
- data/gems/server/exe/itsi +33 -74
- data/gems/server/itsi-server.gemspec +3 -2
- data/gems/server/lib/itsi/{request.rb → http_request.rb} +29 -5
- data/gems/server/lib/itsi/http_response.rb +39 -0
- data/gems/server/lib/itsi/server/Itsi.rb +11 -19
- data/gems/server/lib/itsi/server/config/dsl.rb +506 -0
- data/gems/server/lib/itsi/server/config.rb +103 -8
- data/gems/server/lib/itsi/server/default_app/default_app.rb +38 -0
- data/gems/server/lib/itsi/server/grpc_interface.rb +213 -0
- data/gems/server/lib/itsi/server/rack/handler/itsi.rb +8 -17
- data/gems/server/lib/itsi/server/rack_interface.rb +23 -4
- data/gems/server/lib/itsi/server/scheduler_interface.rb +1 -1
- data/gems/server/lib/itsi/server/scheduler_mode.rb +4 -0
- data/gems/server/lib/itsi/server/signal_trap.rb +7 -1
- data/gems/server/lib/itsi/server/version.rb +1 -1
- data/gems/server/lib/itsi/server.rb +74 -63
- data/gems/server/lib/itsi/standard_headers.rb +86 -0
- data/gems/server/test/helpers/test_helper.rb +12 -12
- data/gems/server/test/test_itsi_server.rb +2 -2
- data/lib/itsi/version.rb +1 -1
- data/sandbox/itsi_file/Gemfile +11 -0
- data/sandbox/itsi_file/Gemfile.lock +69 -0
- data/sandbox/itsi_file/Itsi.rb +276 -0
- data/sandbox/itsi_file/error.html +2 -0
- data/sandbox/itsi_file/organisations_controller.rb +20 -0
- data/sandbox/itsi_file/public/assets/image.png +0 -0
- data/sandbox/itsi_file/public/assets/index.html +1 -0
- data/sandbox/itsi_sandbox_hanami/Gemfile.lock +2 -2
- data/sandbox/itsi_sandbox_rack/Gemfile.lock +2 -2
- data/sandbox/itsi_sandbox_rack/config.ru +2 -15
- data/sandbox/itsi_sandbox_rails/.dockerignore +2 -5
- data/sandbox/itsi_sandbox_rails/.github/workflows/ci.yml +1 -1
- data/sandbox/itsi_sandbox_rails/.gitignore +2 -1
- data/sandbox/itsi_sandbox_rails/Dockerfile +6 -9
- data/sandbox/itsi_sandbox_rails/Gemfile +16 -22
- data/sandbox/itsi_sandbox_rails/Gemfile.lock +100 -225
- data/sandbox/itsi_sandbox_rails/app/assets/config/manifest.js +4 -0
- data/sandbox/itsi_sandbox_rails/app/assets/stylesheets/application.css +11 -6
- data/sandbox/itsi_sandbox_rails/app/channels/application_cable/channel.rb +4 -0
- data/sandbox/itsi_sandbox_rails/app/channels/application_cable/connection.rb +4 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/live_controller.rb +7 -8
- data/sandbox/itsi_sandbox_rails/app/controllers/uploads_controller.rb +0 -3
- data/sandbox/itsi_sandbox_rails/app/views/layouts/application.html.erb +2 -7
- data/sandbox/itsi_sandbox_rails/bin/docker-entrypoint +3 -4
- data/sandbox/itsi_sandbox_rails/bin/setup +8 -5
- data/sandbox/itsi_sandbox_rails/config/application.rb +1 -35
- data/sandbox/itsi_sandbox_rails/config/cable.yml +3 -10
- data/sandbox/itsi_sandbox_rails/config/credentials.yml.enc +1 -1
- data/sandbox/itsi_sandbox_rails/config/database.yml +9 -19
- data/sandbox/itsi_sandbox_rails/config/environment.rb +1 -1
- data/sandbox/itsi_sandbox_rails/config/environments/development.rb +21 -12
- data/sandbox/itsi_sandbox_rails/config/environments/production.rb +49 -34
- data/sandbox/itsi_sandbox_rails/config/environments/test.rb +19 -5
- data/sandbox/itsi_sandbox_rails/config/initializers/assets.rb +5 -0
- data/sandbox/itsi_sandbox_rails/config/initializers/filter_parameter_logging.rb +1 -1
- data/sandbox/itsi_sandbox_rails/config/initializers/permissions_policy.rb +13 -0
- data/sandbox/itsi_sandbox_rails/config/puma.rb +2 -9
- data/sandbox/itsi_sandbox_rails/config.ru +0 -1
- data/sandbox/itsi_sandbox_rails/db/migrate/20250301041554_create_posts.rb +1 -1
- data/sandbox/itsi_sandbox_rails/db/schema.rb +2 -2
- data/sandbox/itsi_sandbox_rails/lib/assets/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/public/404.html +66 -113
- data/sandbox/itsi_sandbox_rails/public/406-unsupported-browser.html +65 -113
- data/sandbox/itsi_sandbox_rails/public/422.html +66 -113
- data/sandbox/itsi_sandbox_rails/public/500.html +65 -113
- data/sandbox/itsi_sandbox_rails/public/icon.png +0 -0
- data/sandbox/itsi_sandbox_rails/public/icon.svg +2 -2
- data/sandbox/itsi_sandbox_rails/test/channels/application_cable/connection_test.rb +13 -0
- data/sandbox/itsi_sandbox_roda/Gemfile.lock +3 -10
- data/tasks.txt +72 -35
- metadata +89 -139
- data/crates/itsi_server/src/body_proxy/mod.rs +0 -2
- data/crates/itsi_server/src/request/itsi_request.rs +0 -298
- data/crates/itsi_server/src/request/mod.rs +0 -1
- data/crates/itsi_server/src/response/mod.rs +0 -1
- data/crates/itsi_server/src/server/itsi_server.rs +0 -288
- data/gems/scheduler/ext/itsi_error/Cargo.lock +0 -368
- data/gems/scheduler/ext/itsi_error/Cargo.toml +0 -11
- data/gems/scheduler/ext/itsi_error/src/from.rs +0 -68
- data/gems/scheduler/ext/itsi_error/src/lib.rs +0 -24
- data/gems/scheduler/ext/itsi_instrument_entry/Cargo.toml +0 -15
- data/gems/scheduler/ext/itsi_instrument_entry/src/lib.rs +0 -31
- data/gems/scheduler/ext/itsi_rb_helpers/Cargo.lock +0 -355
- data/gems/scheduler/ext/itsi_rb_helpers/Cargo.toml +0 -10
- data/gems/scheduler/ext/itsi_rb_helpers/src/heap_value.rs +0 -121
- data/gems/scheduler/ext/itsi_rb_helpers/src/lib.rs +0 -201
- data/gems/scheduler/ext/itsi_scheduler/Cargo.toml +0 -24
- data/gems/scheduler/ext/itsi_scheduler/extconf.rb +0 -6
- data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/io_helpers.rs +0 -56
- data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/io_waiter.rs +0 -44
- data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/timer.rs +0 -44
- data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler.rs +0 -308
- data/gems/scheduler/ext/itsi_scheduler/src/lib.rs +0 -38
- data/gems/scheduler/ext/itsi_server/Cargo.lock +0 -2956
- data/gems/scheduler/ext/itsi_server/Cargo.toml +0 -50
- data/gems/scheduler/ext/itsi_server/extconf.rb +0 -6
- data/gems/scheduler/ext/itsi_server/src/body_proxy/big_bytes.rs +0 -104
- data/gems/scheduler/ext/itsi_server/src/body_proxy/itsi_body_proxy.rs +0 -122
- data/gems/scheduler/ext/itsi_server/src/body_proxy/mod.rs +0 -2
- data/gems/scheduler/ext/itsi_server/src/env.rs +0 -43
- data/gems/scheduler/ext/itsi_server/src/lib.rs +0 -180
- data/gems/scheduler/ext/itsi_server/src/request/itsi_request.rs +0 -298
- data/gems/scheduler/ext/itsi_server/src/request/mod.rs +0 -1
- data/gems/scheduler/ext/itsi_server/src/response/itsi_response.rs +0 -357
- data/gems/scheduler/ext/itsi_server/src/response/mod.rs +0 -1
- data/gems/scheduler/ext/itsi_server/src/server/bind.rs +0 -174
- data/gems/scheduler/ext/itsi_server/src/server/bind_protocol.rs +0 -37
- data/gems/scheduler/ext/itsi_server/src/server/io_stream.rs +0 -104
- data/gems/scheduler/ext/itsi_server/src/server/itsi_server.rs +0 -288
- data/gems/scheduler/ext/itsi_server/src/server/lifecycle_event.rs +0 -9
- data/gems/scheduler/ext/itsi_server/src/server/listener.rs +0 -318
- data/gems/scheduler/ext/itsi_server/src/server/mod.rs +0 -11
- data/gems/scheduler/ext/itsi_server/src/server/process_worker.rs +0 -203
- data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +0 -260
- data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/mod.rs +0 -27
- data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/single_mode.rs +0 -276
- data/gems/scheduler/ext/itsi_server/src/server/signal.rs +0 -74
- data/gems/scheduler/ext/itsi_server/src/server/thread_worker.rs +0 -399
- data/gems/scheduler/ext/itsi_server/src/server/tls/locked_dir_cache.rs +0 -132
- data/gems/scheduler/ext/itsi_server/src/server/tls.rs +0 -265
- data/gems/scheduler/ext/itsi_tracing/Cargo.lock +0 -274
- data/gems/scheduler/ext/itsi_tracing/Cargo.toml +0 -16
- data/gems/scheduler/ext/itsi_tracing/src/lib.rs +0 -58
- data/gems/server/ext/itsi_error/Cargo.lock +0 -368
- data/gems/server/ext/itsi_error/Cargo.toml +0 -11
- data/gems/server/ext/itsi_error/src/from.rs +0 -68
- data/gems/server/ext/itsi_error/src/lib.rs +0 -24
- data/gems/server/ext/itsi_instrument_entry/Cargo.toml +0 -15
- data/gems/server/ext/itsi_instrument_entry/src/lib.rs +0 -31
- data/gems/server/ext/itsi_rb_helpers/Cargo.lock +0 -355
- data/gems/server/ext/itsi_rb_helpers/Cargo.toml +0 -10
- data/gems/server/ext/itsi_rb_helpers/src/heap_value.rs +0 -121
- data/gems/server/ext/itsi_rb_helpers/src/lib.rs +0 -201
- data/gems/server/ext/itsi_scheduler/Cargo.toml +0 -24
- data/gems/server/ext/itsi_scheduler/extconf.rb +0 -6
- data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/io_helpers.rs +0 -56
- data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/io_waiter.rs +0 -44
- data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/timer.rs +0 -44
- data/gems/server/ext/itsi_scheduler/src/itsi_scheduler.rs +0 -308
- data/gems/server/ext/itsi_scheduler/src/lib.rs +0 -38
- data/gems/server/ext/itsi_server/Cargo.lock +0 -2956
- data/gems/server/ext/itsi_server/Cargo.toml +0 -50
- data/gems/server/ext/itsi_server/extconf.rb +0 -6
- data/gems/server/ext/itsi_server/src/body_proxy/big_bytes.rs +0 -104
- data/gems/server/ext/itsi_server/src/body_proxy/itsi_body_proxy.rs +0 -122
- data/gems/server/ext/itsi_server/src/body_proxy/mod.rs +0 -2
- data/gems/server/ext/itsi_server/src/env.rs +0 -43
- data/gems/server/ext/itsi_server/src/lib.rs +0 -180
- data/gems/server/ext/itsi_server/src/request/mod.rs +0 -1
- data/gems/server/ext/itsi_server/src/response/itsi_response.rs +0 -357
- data/gems/server/ext/itsi_server/src/response/mod.rs +0 -1
- data/gems/server/ext/itsi_server/src/server/bind.rs +0 -174
- data/gems/server/ext/itsi_server/src/server/bind_protocol.rs +0 -37
- data/gems/server/ext/itsi_server/src/server/io_stream.rs +0 -104
- data/gems/server/ext/itsi_server/src/server/itsi_server.rs +0 -288
- data/gems/server/ext/itsi_server/src/server/lifecycle_event.rs +0 -9
- data/gems/server/ext/itsi_server/src/server/listener.rs +0 -318
- data/gems/server/ext/itsi_server/src/server/mod.rs +0 -11
- data/gems/server/ext/itsi_server/src/server/process_worker.rs +0 -203
- data/gems/server/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +0 -260
- data/gems/server/ext/itsi_server/src/server/serve_strategy/mod.rs +0 -27
- data/gems/server/ext/itsi_server/src/server/serve_strategy/single_mode.rs +0 -276
- data/gems/server/ext/itsi_server/src/server/signal.rs +0 -74
- data/gems/server/ext/itsi_server/src/server/thread_worker.rs +0 -399
- data/gems/server/ext/itsi_server/src/server/tls/locked_dir_cache.rs +0 -132
- data/gems/server/ext/itsi_server/src/server/tls.rs +0 -265
- data/gems/server/ext/itsi_tracing/Cargo.lock +0 -274
- data/gems/server/ext/itsi_tracing/Cargo.toml +0 -16
- data/gems/server/ext/itsi_tracing/src/lib.rs +0 -58
- data/gems/server/lib/itsi/server/options_dsl.rb +0 -401
- data/gems/server/lib/itsi/stream_io.rb +0 -38
- data/location_dsl.rb +0 -381
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/docker-setup.sample +0 -3
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-app-boot.sample +0 -3
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-deploy.sample +0 -14
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-proxy-reboot.sample +0 -3
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-app-boot.sample +0 -3
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-build.sample +0 -51
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-connect.sample +0 -47
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-deploy.sample +0 -109
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-proxy-reboot.sample +0 -3
- data/sandbox/itsi_sandbox_rails/.kamal/secrets +0 -17
- data/sandbox/itsi_sandbox_rails/bin/dev +0 -2
- data/sandbox/itsi_sandbox_rails/bin/jobs +0 -6
- data/sandbox/itsi_sandbox_rails/bin/kamal +0 -27
- data/sandbox/itsi_sandbox_rails/bin/thrust +0 -5
- data/sandbox/itsi_sandbox_rails/config/cache.yml +0 -16
- data/sandbox/itsi_sandbox_rails/config/deploy.yml +0 -116
- data/sandbox/itsi_sandbox_rails/config/queue.yml +0 -18
- data/sandbox/itsi_sandbox_rails/config/recurring.yml +0 -10
- data/sandbox/itsi_sandbox_rails/db/cable_schema.rb +0 -11
- data/sandbox/itsi_sandbox_rails/db/cache_schema.rb +0 -14
- data/sandbox/itsi_sandbox_rails/db/queue_schema.rb +0 -129
- data/sandbox/itsi_sandbox_rails/public/400.html +0 -114
- data/sandbox/itsi_sandbox_rails/test/fixtures/posts.yml +0 -9
- data/sandbox/itsi_sandbox_rails/test/models/post_test.rb +0 -7
- /data/{sandbox/itsi_sandbox_rails/script/.keep → crates/_index.md} +0 -0
- /data/gems/server/lib/itsi/{index.html → server/default_app/index.html} +0 -0
@@ -1,355 +0,0 @@
|
|
1
|
-
# This file is automatically @generated by Cargo.
|
2
|
-
# It is not intended for manual editing.
|
3
|
-
version = 4
|
4
|
-
|
5
|
-
[[package]]
|
6
|
-
name = "aho-corasick"
|
7
|
-
version = "1.1.3"
|
8
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
-
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
10
|
-
dependencies = [
|
11
|
-
"memchr",
|
12
|
-
]
|
13
|
-
|
14
|
-
[[package]]
|
15
|
-
name = "bindgen"
|
16
|
-
version = "0.69.5"
|
17
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
19
|
-
dependencies = [
|
20
|
-
"bitflags",
|
21
|
-
"cexpr",
|
22
|
-
"clang-sys",
|
23
|
-
"itertools",
|
24
|
-
"lazy_static",
|
25
|
-
"lazycell",
|
26
|
-
"proc-macro2",
|
27
|
-
"quote",
|
28
|
-
"regex",
|
29
|
-
"rustc-hash",
|
30
|
-
"shlex",
|
31
|
-
"syn",
|
32
|
-
]
|
33
|
-
|
34
|
-
[[package]]
|
35
|
-
name = "bitflags"
|
36
|
-
version = "2.8.0"
|
37
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
38
|
-
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
39
|
-
|
40
|
-
[[package]]
|
41
|
-
name = "bytes"
|
42
|
-
version = "1.10.0"
|
43
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
44
|
-
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
45
|
-
|
46
|
-
[[package]]
|
47
|
-
name = "cexpr"
|
48
|
-
version = "0.6.0"
|
49
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
50
|
-
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
51
|
-
dependencies = [
|
52
|
-
"nom",
|
53
|
-
]
|
54
|
-
|
55
|
-
[[package]]
|
56
|
-
name = "cfg-if"
|
57
|
-
version = "1.0.0"
|
58
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
59
|
-
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
60
|
-
|
61
|
-
[[package]]
|
62
|
-
name = "clang-sys"
|
63
|
-
version = "1.8.1"
|
64
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
65
|
-
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
66
|
-
dependencies = [
|
67
|
-
"glob",
|
68
|
-
"libc",
|
69
|
-
"libloading",
|
70
|
-
]
|
71
|
-
|
72
|
-
[[package]]
|
73
|
-
name = "either"
|
74
|
-
version = "1.14.0"
|
75
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
76
|
-
checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d"
|
77
|
-
|
78
|
-
[[package]]
|
79
|
-
name = "glob"
|
80
|
-
version = "0.3.2"
|
81
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
82
|
-
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
83
|
-
|
84
|
-
[[package]]
|
85
|
-
name = "itertools"
|
86
|
-
version = "0.12.1"
|
87
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
88
|
-
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
89
|
-
dependencies = [
|
90
|
-
"either",
|
91
|
-
]
|
92
|
-
|
93
|
-
[[package]]
|
94
|
-
name = "itsi_rb_helpers"
|
95
|
-
version = "0.1.0"
|
96
|
-
dependencies = [
|
97
|
-
"magnus",
|
98
|
-
"rb-sys",
|
99
|
-
]
|
100
|
-
|
101
|
-
[[package]]
|
102
|
-
name = "lazy_static"
|
103
|
-
version = "1.5.0"
|
104
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
105
|
-
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
106
|
-
|
107
|
-
[[package]]
|
108
|
-
name = "lazycell"
|
109
|
-
version = "1.3.0"
|
110
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
111
|
-
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
112
|
-
|
113
|
-
[[package]]
|
114
|
-
name = "libc"
|
115
|
-
version = "0.2.170"
|
116
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
117
|
-
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
|
118
|
-
|
119
|
-
[[package]]
|
120
|
-
name = "libloading"
|
121
|
-
version = "0.8.6"
|
122
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
123
|
-
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
124
|
-
dependencies = [
|
125
|
-
"cfg-if",
|
126
|
-
"windows-targets",
|
127
|
-
]
|
128
|
-
|
129
|
-
[[package]]
|
130
|
-
name = "magnus"
|
131
|
-
version = "0.7.1"
|
132
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
133
|
-
checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab"
|
134
|
-
dependencies = [
|
135
|
-
"bytes",
|
136
|
-
"magnus-macros",
|
137
|
-
"rb-sys",
|
138
|
-
"rb-sys-env",
|
139
|
-
"seq-macro",
|
140
|
-
]
|
141
|
-
|
142
|
-
[[package]]
|
143
|
-
name = "magnus-macros"
|
144
|
-
version = "0.6.0"
|
145
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
146
|
-
checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
147
|
-
dependencies = [
|
148
|
-
"proc-macro2",
|
149
|
-
"quote",
|
150
|
-
"syn",
|
151
|
-
]
|
152
|
-
|
153
|
-
[[package]]
|
154
|
-
name = "memchr"
|
155
|
-
version = "2.7.4"
|
156
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
157
|
-
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
158
|
-
|
159
|
-
[[package]]
|
160
|
-
name = "minimal-lexical"
|
161
|
-
version = "0.2.1"
|
162
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
163
|
-
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
164
|
-
|
165
|
-
[[package]]
|
166
|
-
name = "nom"
|
167
|
-
version = "7.1.3"
|
168
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
169
|
-
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
170
|
-
dependencies = [
|
171
|
-
"memchr",
|
172
|
-
"minimal-lexical",
|
173
|
-
]
|
174
|
-
|
175
|
-
[[package]]
|
176
|
-
name = "proc-macro2"
|
177
|
-
version = "1.0.93"
|
178
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
179
|
-
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
180
|
-
dependencies = [
|
181
|
-
"unicode-ident",
|
182
|
-
]
|
183
|
-
|
184
|
-
[[package]]
|
185
|
-
name = "quote"
|
186
|
-
version = "1.0.38"
|
187
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
188
|
-
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
189
|
-
dependencies = [
|
190
|
-
"proc-macro2",
|
191
|
-
]
|
192
|
-
|
193
|
-
[[package]]
|
194
|
-
name = "rb-sys"
|
195
|
-
version = "0.9.110"
|
196
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
197
|
-
checksum = "56cf964f8e44115e50009921ea3d3791b6f74d1ae6d6ed37114fbe03a1cd7308"
|
198
|
-
dependencies = [
|
199
|
-
"rb-sys-build",
|
200
|
-
]
|
201
|
-
|
202
|
-
[[package]]
|
203
|
-
name = "rb-sys-build"
|
204
|
-
version = "0.9.110"
|
205
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
206
|
-
checksum = "161480347f56473107d4135643b6b1909331eec61445e113b256708a28b691c5"
|
207
|
-
dependencies = [
|
208
|
-
"bindgen",
|
209
|
-
"lazy_static",
|
210
|
-
"proc-macro2",
|
211
|
-
"quote",
|
212
|
-
"regex",
|
213
|
-
"shell-words",
|
214
|
-
"syn",
|
215
|
-
]
|
216
|
-
|
217
|
-
[[package]]
|
218
|
-
name = "rb-sys-env"
|
219
|
-
version = "0.1.2"
|
220
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
221
|
-
checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
222
|
-
|
223
|
-
[[package]]
|
224
|
-
name = "regex"
|
225
|
-
version = "1.11.1"
|
226
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
227
|
-
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
228
|
-
dependencies = [
|
229
|
-
"aho-corasick",
|
230
|
-
"memchr",
|
231
|
-
"regex-automata",
|
232
|
-
"regex-syntax",
|
233
|
-
]
|
234
|
-
|
235
|
-
[[package]]
|
236
|
-
name = "regex-automata"
|
237
|
-
version = "0.4.9"
|
238
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
239
|
-
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
240
|
-
dependencies = [
|
241
|
-
"aho-corasick",
|
242
|
-
"memchr",
|
243
|
-
"regex-syntax",
|
244
|
-
]
|
245
|
-
|
246
|
-
[[package]]
|
247
|
-
name = "regex-syntax"
|
248
|
-
version = "0.8.5"
|
249
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
250
|
-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
251
|
-
|
252
|
-
[[package]]
|
253
|
-
name = "rustc-hash"
|
254
|
-
version = "1.1.0"
|
255
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
256
|
-
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
257
|
-
|
258
|
-
[[package]]
|
259
|
-
name = "seq-macro"
|
260
|
-
version = "0.3.5"
|
261
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
262
|
-
checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
|
263
|
-
|
264
|
-
[[package]]
|
265
|
-
name = "shell-words"
|
266
|
-
version = "1.1.0"
|
267
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
268
|
-
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
269
|
-
|
270
|
-
[[package]]
|
271
|
-
name = "shlex"
|
272
|
-
version = "1.3.0"
|
273
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
274
|
-
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
275
|
-
|
276
|
-
[[package]]
|
277
|
-
name = "syn"
|
278
|
-
version = "2.0.98"
|
279
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
280
|
-
checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
|
281
|
-
dependencies = [
|
282
|
-
"proc-macro2",
|
283
|
-
"quote",
|
284
|
-
"unicode-ident",
|
285
|
-
]
|
286
|
-
|
287
|
-
[[package]]
|
288
|
-
name = "unicode-ident"
|
289
|
-
version = "1.0.17"
|
290
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
291
|
-
checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
|
292
|
-
|
293
|
-
[[package]]
|
294
|
-
name = "windows-targets"
|
295
|
-
version = "0.52.6"
|
296
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
297
|
-
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
298
|
-
dependencies = [
|
299
|
-
"windows_aarch64_gnullvm",
|
300
|
-
"windows_aarch64_msvc",
|
301
|
-
"windows_i686_gnu",
|
302
|
-
"windows_i686_gnullvm",
|
303
|
-
"windows_i686_msvc",
|
304
|
-
"windows_x86_64_gnu",
|
305
|
-
"windows_x86_64_gnullvm",
|
306
|
-
"windows_x86_64_msvc",
|
307
|
-
]
|
308
|
-
|
309
|
-
[[package]]
|
310
|
-
name = "windows_aarch64_gnullvm"
|
311
|
-
version = "0.52.6"
|
312
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
313
|
-
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
314
|
-
|
315
|
-
[[package]]
|
316
|
-
name = "windows_aarch64_msvc"
|
317
|
-
version = "0.52.6"
|
318
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
319
|
-
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
320
|
-
|
321
|
-
[[package]]
|
322
|
-
name = "windows_i686_gnu"
|
323
|
-
version = "0.52.6"
|
324
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
325
|
-
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
326
|
-
|
327
|
-
[[package]]
|
328
|
-
name = "windows_i686_gnullvm"
|
329
|
-
version = "0.52.6"
|
330
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
331
|
-
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
332
|
-
|
333
|
-
[[package]]
|
334
|
-
name = "windows_i686_msvc"
|
335
|
-
version = "0.52.6"
|
336
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
337
|
-
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
338
|
-
|
339
|
-
[[package]]
|
340
|
-
name = "windows_x86_64_gnu"
|
341
|
-
version = "0.52.6"
|
342
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
343
|
-
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
344
|
-
|
345
|
-
[[package]]
|
346
|
-
name = "windows_x86_64_gnullvm"
|
347
|
-
version = "0.52.6"
|
348
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
349
|
-
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
350
|
-
|
351
|
-
[[package]]
|
352
|
-
name = "windows_x86_64_msvc"
|
353
|
-
version = "0.52.6"
|
354
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
355
|
-
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
@@ -1,121 +0,0 @@
|
|
1
|
-
use magnus::IntoValue;
|
2
|
-
use magnus::rb_sys::AsRawValue;
|
3
|
-
use magnus::value::BoxValue;
|
4
|
-
use magnus::{Ruby, Value, value::ReprValue};
|
5
|
-
use std::fmt::{self, Debug, Formatter};
|
6
|
-
use std::ops::Deref;
|
7
|
-
|
8
|
-
/// HeapVal is a wrapper for heap-allocated magnus ReprVa;ies
|
9
|
-
/// that is marked as thread-safe(Send and Sync)
|
10
|
-
/// It's up to the user to actually ensure this though,
|
11
|
-
/// typically by only interacting with the value from a thread which
|
12
|
-
/// holds the GVL.
|
13
|
-
pub struct HeapValue<T>(pub BoxValue<T>)
|
14
|
-
where
|
15
|
-
T: ReprValue;
|
16
|
-
|
17
|
-
impl<T> PartialEq for HeapValue<T>
|
18
|
-
where
|
19
|
-
T: ReprValue,
|
20
|
-
{
|
21
|
-
fn eq(&self, other: &Self) -> bool {
|
22
|
-
self.0.as_raw() == other.0.as_raw()
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
impl<T> Deref for HeapValue<T>
|
27
|
-
where
|
28
|
-
T: ReprValue,
|
29
|
-
{
|
30
|
-
type Target = T;
|
31
|
-
|
32
|
-
fn deref(&self) -> &Self::Target {
|
33
|
-
&self.0
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
impl<T> HeapValue<T>
|
38
|
-
where
|
39
|
-
T: ReprValue,
|
40
|
-
{
|
41
|
-
pub fn inner(self) -> T {
|
42
|
-
*self.0
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
impl<T> IntoValue for HeapValue<T>
|
47
|
-
where
|
48
|
-
T: ReprValue,
|
49
|
-
{
|
50
|
-
fn into_value_with(self, _: &Ruby) -> Value {
|
51
|
-
self.0.into_value()
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
impl<T> From<T> for HeapValue<T>
|
56
|
-
where
|
57
|
-
T: ReprValue,
|
58
|
-
{
|
59
|
-
fn from(value: T) -> Self {
|
60
|
-
HeapValue(BoxValue::new(value))
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
impl<T> Clone for HeapValue<T>
|
65
|
-
where
|
66
|
-
T: ReprValue + Clone,
|
67
|
-
{
|
68
|
-
fn clone(&self) -> Self {
|
69
|
-
HeapValue(BoxValue::new(*self.0.deref()))
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
impl<T> Debug for HeapValue<T>
|
74
|
-
where
|
75
|
-
T: ReprValue + Debug,
|
76
|
-
{
|
77
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
78
|
-
write!(f, "{:?}", self.0)
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
unsafe impl<T> Send for HeapValue<T> where T: ReprValue {}
|
83
|
-
unsafe impl<T> Sync for HeapValue<T> where T: ReprValue {}
|
84
|
-
|
85
|
-
/// HeapVal is a wrapper for heap-allocated magnus Values
|
86
|
-
/// that is marked as thread-safe(Send and Sync)
|
87
|
-
/// It's up to the user to actually ensure this though,
|
88
|
-
/// typically by only interacting with the value from a thread which
|
89
|
-
/// holds the GVL.
|
90
|
-
pub struct HeapVal(HeapValue<Value>);
|
91
|
-
impl Deref for HeapVal {
|
92
|
-
type Target = Value;
|
93
|
-
|
94
|
-
fn deref(&self) -> &Self::Target {
|
95
|
-
&self.0
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
impl IntoValue for HeapVal {
|
100
|
-
fn into_value_with(self, _: &Ruby) -> Value {
|
101
|
-
self.0.into_value()
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
impl From<Value> for HeapVal {
|
106
|
-
fn from(value: Value) -> Self {
|
107
|
-
HeapVal(HeapValue(BoxValue::new(value)))
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
impl Clone for HeapVal {
|
112
|
-
fn clone(&self) -> Self {
|
113
|
-
HeapVal(HeapValue(BoxValue::new(*self.0.deref())))
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
impl Debug for HeapVal {
|
118
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
119
|
-
write!(f, "{:?}", self.0)
|
120
|
-
}
|
121
|
-
}
|
@@ -1,201 +0,0 @@
|
|
1
|
-
use std::{os::raw::c_void, ptr::null_mut};
|
2
|
-
|
3
|
-
use magnus::{
|
4
|
-
RArray, Ruby, Thread, Value,
|
5
|
-
block::Proc,
|
6
|
-
rb_sys::FromRawValue,
|
7
|
-
value::{LazyId, ReprValue},
|
8
|
-
};
|
9
|
-
use rb_sys::{
|
10
|
-
rb_thread_call_with_gvl, rb_thread_call_without_gvl, rb_thread_create, rb_thread_schedule,
|
11
|
-
rb_thread_wakeup,
|
12
|
-
};
|
13
|
-
|
14
|
-
mod heap_value;
|
15
|
-
pub use heap_value::{HeapVal, HeapValue};
|
16
|
-
static ID_FORK: LazyId = LazyId::new("fork");
|
17
|
-
static ID_LIST: LazyId = LazyId::new("list");
|
18
|
-
static ID_EQ: LazyId = LazyId::new("==");
|
19
|
-
static ID_ALIVE: LazyId = LazyId::new("alive?");
|
20
|
-
static ID_THREAD_VARIABLE_GET: LazyId = LazyId::new("thread_variable_get");
|
21
|
-
static ID_BACKTRACE: LazyId = LazyId::new("backtrace");
|
22
|
-
|
23
|
-
pub fn schedule_thread() {
|
24
|
-
unsafe {
|
25
|
-
rb_thread_schedule();
|
26
|
-
};
|
27
|
-
}
|
28
|
-
pub fn create_ruby_thread<F>(f: F) -> Thread
|
29
|
-
where
|
30
|
-
F: FnOnce() + Send + 'static,
|
31
|
-
{
|
32
|
-
extern "C" fn trampoline<F>(ptr: *mut c_void) -> u64
|
33
|
-
where
|
34
|
-
F: FnOnce(),
|
35
|
-
{
|
36
|
-
// Reconstruct the boxed Option<F> that holds our closure.
|
37
|
-
let boxed_closure: Box<Option<F>> = unsafe { Box::from_raw(ptr as *mut Option<F>) };
|
38
|
-
// Extract the closure. (The Option should be Some; panic otherwise.)
|
39
|
-
let closure = (*boxed_closure).expect("Closure already taken");
|
40
|
-
// Call the closure and return its result.
|
41
|
-
closure();
|
42
|
-
0
|
43
|
-
}
|
44
|
-
|
45
|
-
// Box the closure (wrapped in an Option) to create a stable pointer.
|
46
|
-
let boxed_closure = Box::new(Some(f));
|
47
|
-
let ptr = Box::into_raw(boxed_closure) as *mut c_void;
|
48
|
-
|
49
|
-
// Call rb_thread_create with our trampoline and boxed closure.
|
50
|
-
unsafe {
|
51
|
-
let thread = rb_thread_create(Some(trampoline::<F>), ptr);
|
52
|
-
rb_thread_wakeup(thread);
|
53
|
-
rb_thread_schedule();
|
54
|
-
Thread::from_value(Value::from_raw(thread)).unwrap()
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
pub fn call_without_gvl<F, R>(f: F) -> R
|
59
|
-
where
|
60
|
-
F: FnOnce() -> R,
|
61
|
-
{
|
62
|
-
// This is the function that Ruby calls “in the background” with the GVL released.
|
63
|
-
extern "C" fn trampoline<F, R>(arg: *mut c_void) -> *mut c_void
|
64
|
-
where
|
65
|
-
F: FnOnce() -> R,
|
66
|
-
{
|
67
|
-
// 1) Reconstruct the Box that holds our closure
|
68
|
-
let closure_ptr = arg as *mut Option<F>;
|
69
|
-
let closure = unsafe { (*closure_ptr).take().expect("Closure already taken") };
|
70
|
-
|
71
|
-
// 2) Call the user’s closure
|
72
|
-
let result = closure();
|
73
|
-
|
74
|
-
// 3) Box up the result so we can return a pointer to it
|
75
|
-
let boxed_result = Box::new(result);
|
76
|
-
Box::into_raw(boxed_result) as *mut c_void
|
77
|
-
}
|
78
|
-
|
79
|
-
// Box up the closure so we have a stable pointer
|
80
|
-
let mut closure_opt = Some(f);
|
81
|
-
let closure_ptr = &mut closure_opt as *mut Option<F> as *mut c_void;
|
82
|
-
|
83
|
-
// 4) Actually call `rb_thread_call_without_gvl`
|
84
|
-
let raw_result_ptr = unsafe {
|
85
|
-
rb_thread_call_without_gvl(Some(trampoline::<F, R>), closure_ptr, None, null_mut())
|
86
|
-
};
|
87
|
-
|
88
|
-
// 5) Convert the returned pointer back into R
|
89
|
-
let result_box = unsafe { Box::from_raw(raw_result_ptr as *mut R) };
|
90
|
-
*result_box
|
91
|
-
}
|
92
|
-
|
93
|
-
pub fn call_with_gvl<F, R>(f: F) -> R
|
94
|
-
where
|
95
|
-
F: FnOnce(Ruby) -> R,
|
96
|
-
{
|
97
|
-
extern "C" fn trampoline<F, R>(arg: *mut c_void) -> *mut c_void
|
98
|
-
where
|
99
|
-
F: FnOnce(Ruby) -> R,
|
100
|
-
{
|
101
|
-
// 1) Reconstruct the Box that holds our closure
|
102
|
-
let closure_ptr = arg as *mut Option<F>;
|
103
|
-
let closure = unsafe { (*closure_ptr).take().expect("Closure already taken") };
|
104
|
-
|
105
|
-
// 2) Call the user’s closure
|
106
|
-
let result = closure(Ruby::get().unwrap());
|
107
|
-
|
108
|
-
// 3) Box up the result so we can return a pointer to it
|
109
|
-
let boxed_result = Box::new(result);
|
110
|
-
Box::into_raw(boxed_result) as *mut c_void
|
111
|
-
}
|
112
|
-
|
113
|
-
// Box up the closure so we have a stable pointer
|
114
|
-
let mut closure_opt = Some(f);
|
115
|
-
let closure_ptr = &mut closure_opt as *mut Option<F> as *mut c_void;
|
116
|
-
|
117
|
-
// 4) Actually call `rb_thread_call_without_gvl`
|
118
|
-
let raw_result_ptr = unsafe { rb_thread_call_with_gvl(Some(trampoline::<F, R>), closure_ptr) };
|
119
|
-
|
120
|
-
// 5) Convert the returned pointer back into R
|
121
|
-
let result_box = unsafe { Box::from_raw(raw_result_ptr as *mut R) };
|
122
|
-
*result_box
|
123
|
-
}
|
124
|
-
|
125
|
-
pub fn fork(after_fork: Option<HeapValue<Proc>>) -> Option<i32> {
|
126
|
-
let ruby = Ruby::get().unwrap();
|
127
|
-
let fork_result = ruby
|
128
|
-
.module_kernel()
|
129
|
-
.funcall::<_, _, Option<i32>>(*ID_FORK, ())
|
130
|
-
.unwrap();
|
131
|
-
if fork_result.is_none() {
|
132
|
-
if let Some(proc) = after_fork {
|
133
|
-
call_proc_and_log_errors(proc)
|
134
|
-
}
|
135
|
-
}
|
136
|
-
fork_result
|
137
|
-
}
|
138
|
-
|
139
|
-
pub fn call_proc_and_log_errors(proc: HeapValue<Proc>) {
|
140
|
-
if let Err(e) = proc.call::<_, Value>(()) {
|
141
|
-
if let Some(value) = e.value() {
|
142
|
-
print_rb_backtrace(value);
|
143
|
-
} else {
|
144
|
-
eprintln!("Error occurred {:?}", e);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
pub fn kill_threads<T>(threads: Vec<T>)
|
150
|
-
where
|
151
|
-
T: ReprValue,
|
152
|
-
{
|
153
|
-
for thr in &threads {
|
154
|
-
let alive: bool = thr
|
155
|
-
.funcall(*ID_ALIVE, ())
|
156
|
-
.expect("Failed to check if thread is alive");
|
157
|
-
if !alive {
|
158
|
-
eprintln!("Thread killed");
|
159
|
-
break;
|
160
|
-
}
|
161
|
-
eprintln!("Killing thread {:?}", thr.as_value());
|
162
|
-
thr.funcall::<_, _, Value>("terminate", ())
|
163
|
-
.expect("Failed to kill thread");
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
pub fn terminate_non_fork_safe_threads() {
|
168
|
-
let ruby = Ruby::get().unwrap();
|
169
|
-
let thread_class = ruby.class_thread();
|
170
|
-
let current: Thread = ruby.thread_current();
|
171
|
-
let threads: RArray = thread_class
|
172
|
-
.funcall(*ID_LIST, ())
|
173
|
-
.expect("Failed to list Ruby threads");
|
174
|
-
|
175
|
-
let non_fork_safe_threads = threads
|
176
|
-
.into_iter()
|
177
|
-
.filter_map(|v| {
|
178
|
-
let v_thread = Thread::from_value(v).unwrap();
|
179
|
-
let non_fork_safe = !v_thread
|
180
|
-
.funcall::<_, _, bool>(*ID_EQ, (current,))
|
181
|
-
.unwrap_or(false)
|
182
|
-
&& !v_thread
|
183
|
-
.funcall::<_, _, bool>(*ID_THREAD_VARIABLE_GET, (ruby.sym_new("fork_safe"),))
|
184
|
-
.unwrap_or(false);
|
185
|
-
if non_fork_safe { Some(v_thread) } else { None }
|
186
|
-
})
|
187
|
-
.collect::<Vec<_>>();
|
188
|
-
|
189
|
-
kill_threads(non_fork_safe_threads);
|
190
|
-
}
|
191
|
-
|
192
|
-
pub fn print_rb_backtrace(rb_err: Value) {
|
193
|
-
let backtrace = rb_err
|
194
|
-
.funcall::<_, _, Vec<String>>(*ID_BACKTRACE, ())
|
195
|
-
.unwrap_or_default();
|
196
|
-
|
197
|
-
eprintln!("Ruby exception {:?}", rb_err);
|
198
|
-
for line in backtrace {
|
199
|
-
eprintln!("{}", line);
|
200
|
-
}
|
201
|
-
}
|