ratomic 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +11 -7
- data/lib/ratomic/version.rb +1 -1
- data/lib/ratomic.rb +17 -1
- data/ratomic.gemspec +1 -0
- data/sig/ratomic.rbs +73 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f7627c4d9c390e791c1d343633f75fffae6e37830bb480069016c804b895697
|
|
4
|
+
data.tar.gz: 5323624b8e73447184f3fdd6aba30e5a54b3ac009ccd047b9b69dfccb81e9e2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 313e69785949da363e2c1aced4aae9a7036a1d97f6442cf306de88733c577a18770e5d86af504ee59934ea984a7d733ec84f58e9c4c88c8de4af4ed602145969
|
|
7
|
+
data.tar.gz: dc7361abcf2ca0d2dcb70f157256a7ac9e76e6d3c1e4f61ca6d94610a602674fbc3b591aac2cfa6ca55ea37e7488b3b2d1223b3de55e86f236117d816a50a42f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.2] - 2026-06-06
|
|
4
|
+
|
|
5
|
+
- Fix `require "ratomic"` for installed gems by resolving the versioned native
|
|
6
|
+
extension layout.
|
|
7
|
+
- Add a regression test for the packaged gem loader path.
|
|
8
|
+
- Keep the curated RBS signatures packaged with the gem.
|
|
9
|
+
|
|
3
10
|
## [0.3.1] - 2026-06-05
|
|
4
11
|
|
|
5
12
|
- Realign `Counter`, `Map`, and `Queue` return semantics with Ruby conventions.
|
data/README.md
CHANGED
|
@@ -12,9 +12,6 @@ Ratomic provides mutable data structures for Ruby Ractors. Its primitives are ba
|
|
|
12
12
|
Ratomic focuses on practical Ractor-safe primitives with a small API surface, clear
|
|
13
13
|
ownership semantics, and honest documentation about sharp edges.
|
|
14
14
|
|
|
15
|
-
`Ratomic::Map` is the current priority: a Ruby-facing concurrent Hash powered by
|
|
16
|
-
DashMap, with atomic per-key operations designed for real Ractor workloads.
|
|
17
|
-
|
|
18
15
|
## Requirements
|
|
19
16
|
|
|
20
17
|
- Ruby 4.0 or newer
|
|
@@ -41,6 +38,8 @@ API documentation is published to GitHub Pages:
|
|
|
41
38
|
|
|
42
39
|
- [mperham.github.io/ratomic](https://mperham.github.io/ratomic/)
|
|
43
40
|
|
|
41
|
+
RBS signatures are included under `sig/` for downstream type checking.
|
|
42
|
+
|
|
44
43
|
## Examples And Benchmarks
|
|
45
44
|
|
|
46
45
|
- [`redis_poc`](./redis_poc) contains local Redis scripts that exercise
|
|
@@ -84,9 +83,10 @@ counter.zero? # => false
|
|
|
84
83
|
|
|
85
84
|
### `Ratomic::Map`
|
|
86
85
|
|
|
87
|
-
`Ratomic::Map` is
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
`Ratomic::Map` is the primary Ractor-safe concurrent Hash primitive in Ratomic.
|
|
87
|
+
It is backed by Rust's DashMap and provides atomic per-key operations for real
|
|
88
|
+
Ractor workloads. It is not a full `Hash` replacement; iteration and arbitrary
|
|
89
|
+
mutable object borrowing are intentionally absent.
|
|
90
90
|
|
|
91
91
|
```ruby
|
|
92
92
|
OFFSETS = Ratomic::Map.new
|
|
@@ -226,12 +226,16 @@ Please read the [Code of Conduct](./CODE_OF_CONDUCT.md) before contributing.
|
|
|
226
226
|
After changing code, run:
|
|
227
227
|
|
|
228
228
|
```bash
|
|
229
|
-
rake
|
|
229
|
+
bundle exec rake
|
|
230
230
|
```
|
|
231
231
|
|
|
232
232
|
This compiles the Rust code and runs the test suite. The test suite writes a
|
|
233
233
|
SimpleCov report to `coverage/index.html` for the Ruby wrapper paths.
|
|
234
234
|
|
|
235
|
+
If you change the public Ruby API, update the curated RBS signatures under
|
|
236
|
+
`sig/ratomic.rbs` and run `bundle exec rake rbs:validate` before release or
|
|
237
|
+
review.
|
|
238
|
+
|
|
235
239
|
## Thanks
|
|
236
240
|
|
|
237
241
|
[Ilya Bylich](https://github.com/iliabylich) wrote and documented his original
|
data/lib/ratomic/version.rb
CHANGED
data/lib/ratomic.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "rbconfig"
|
|
4
|
+
|
|
3
5
|
# Ratomic provides mutable data structures for Ruby Ractors. Its primitives
|
|
4
6
|
# are backed by native Rust concurrency libraries so Ruby code can share useful
|
|
5
7
|
# state across Ractors without falling back to one global lock. Pool uses Ruby
|
|
@@ -9,9 +11,23 @@
|
|
|
9
11
|
module Ratomic
|
|
10
12
|
# Base error class for Ratomic-specific failures.
|
|
11
13
|
class Error < StandardError; end
|
|
14
|
+
|
|
15
|
+
def self.load_native_extension
|
|
16
|
+
ruby_version = RbConfig::CONFIG.fetch("ruby_version")
|
|
17
|
+
versioned_native = File.join("ratomic", ruby_version, "ratomic")
|
|
18
|
+
versioned_path = File.join(__dir__, "ratomic", ruby_version)
|
|
19
|
+
|
|
20
|
+
if File.exist?(File.join(versioned_path, "ratomic.so")) ||
|
|
21
|
+
File.exist?(File.join(versioned_path, "ratomic.bundle"))
|
|
22
|
+
require versioned_native
|
|
23
|
+
else
|
|
24
|
+
require "ratomic/ratomic"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
private_class_method :load_native_extension
|
|
12
28
|
end
|
|
13
29
|
|
|
14
|
-
|
|
30
|
+
Ratomic.send(:load_native_extension)
|
|
15
31
|
require "ratomic/version"
|
|
16
32
|
|
|
17
33
|
require "ratomic/undefined"
|
data/ratomic.gemspec
CHANGED
data/sig/ratomic.rbs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module Ratomic
|
|
2
|
+
class Error < ::StandardError
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
class Undefined
|
|
6
|
+
def inspect: () -> String
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
VERSION: String
|
|
10
|
+
UNDEFINED: Undefined
|
|
11
|
+
|
|
12
|
+
class Counter
|
|
13
|
+
def self.new: () -> Counter
|
|
14
|
+
|
|
15
|
+
def read: () -> Integer
|
|
16
|
+
def value: () -> Integer
|
|
17
|
+
def to_i: () -> Integer
|
|
18
|
+
def zero?: () -> bool
|
|
19
|
+
def increment: (Numeric amt) -> Integer
|
|
20
|
+
def decrement: (Numeric amt) -> Integer
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Map
|
|
24
|
+
def self.new: () -> Map
|
|
25
|
+
|
|
26
|
+
def get: (untyped key) -> untyped
|
|
27
|
+
def []: (untyped key) -> untyped
|
|
28
|
+
def set: (untyped key, untyped value) -> untyped
|
|
29
|
+
def []=: (untyped key, untyped value) -> untyped
|
|
30
|
+
def key?: (untyped key) -> bool
|
|
31
|
+
def include?: (untyped key) -> bool
|
|
32
|
+
def member?: (untyped key) -> bool
|
|
33
|
+
def delete: (untyped key) -> untyped
|
|
34
|
+
def clear: () -> self
|
|
35
|
+
def size: () -> Integer
|
|
36
|
+
def length: () -> Integer
|
|
37
|
+
def empty?: () -> bool
|
|
38
|
+
|
|
39
|
+
def fetch: (untyped key) { (untyped) -> untyped } -> untyped
|
|
40
|
+
| (untyped key, untyped default) -> untyped
|
|
41
|
+
| (untyped key) -> untyped
|
|
42
|
+
|
|
43
|
+
def fetch_and_modify: (untyped key) { (untyped) -> untyped } -> void
|
|
44
|
+
def compute: (untyped key) { (untyped?) -> untyped } -> untyped
|
|
45
|
+
def fetch_or_store: (untyped key) { () -> untyped } -> untyped
|
|
46
|
+
def upsert: (untyped key, untyped initial) { (untyped?) -> untyped } -> untyped
|
|
47
|
+
def increment: (untyped key, ?Numeric by) -> Numeric
|
|
48
|
+
def decrement: (untyped key, ?Numeric by) -> Numeric
|
|
49
|
+
def append: (untyped key, untyped value) -> Array[untyped]
|
|
50
|
+
def add_to_set: (untyped key, untyped value) -> ::Set[untyped]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class Queue
|
|
54
|
+
def self.new: (Integer capacity) -> Queue
|
|
55
|
+
|
|
56
|
+
def push: (untyped item) -> self
|
|
57
|
+
def <<: (untyped item) -> self
|
|
58
|
+
def pop: () -> untyped
|
|
59
|
+
def peek: () -> untyped
|
|
60
|
+
def empty?: () -> bool
|
|
61
|
+
def size: () -> Integer
|
|
62
|
+
def length: () -> Integer
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
class Pool
|
|
66
|
+
def self.new: (?Integer size, ?(Numeric | nil) timeout) { () -> untyped } -> Pool
|
|
67
|
+
|
|
68
|
+
def checkout: () -> untyped
|
|
69
|
+
def checkin: (untyped object) -> nil
|
|
70
|
+
def close: () -> nil
|
|
71
|
+
def with: () { (untyped object) -> untyped } -> untyped
|
|
72
|
+
end
|
|
73
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ratomic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Perham
|
|
@@ -56,6 +56,7 @@ files:
|
|
|
56
56
|
- lib/ratomic/undefined.rb
|
|
57
57
|
- lib/ratomic/version.rb
|
|
58
58
|
- ratomic.gemspec
|
|
59
|
+
- sig/ratomic.rbs
|
|
59
60
|
homepage: https://mperham.github.io/ratomic
|
|
60
61
|
licenses:
|
|
61
62
|
- MIT
|