atomic-ruby 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 258cae699ce52593ad8958202446ff4ec5fffe8cd81771310d9a998dd10a3a09
4
- data.tar.gz: 41af67fd11f30275d176691601f7f72863037583a0ecb70d3159da7d0e10e18a
3
+ metadata.gz: fc55b63bd9de85a395232f89184e97aa80e08e8e082981f2b17012fd1b56b5c0
4
+ data.tar.gz: 25cffc0cbb45f1d145d3b99380decc91a39ef82415833781bed40ba2583286a8
5
5
  SHA512:
6
- metadata.gz: 3c49fea57c186b3f5b99f522d30aa94b5cf073b08e3b2179b58cd4da37daba3af5f8890b0abff209731e0bc4cdb350864b0d4a90e940cb4664763c4038b53f50
7
- data.tar.gz: a4b0521b8a951ccb672e9f138983dc0f55f7fbaaf8a4848d17f9f88ff5dbfd6c4b46208252b45b0fec9cddb3432962711f961ef979d569b0d1962083c00706a6
6
+ metadata.gz: 1420ff50010eec4386301619d4866c1e96aec8f91936e464b2ed56276607fd6dfaf88d0cc5582ee255c06a15928a2b1390f1a2e18ceb443ee0d74fa190a36ee9
7
+ data.tar.gz: 80ceb6dd2348ea38bbd8b63223fc7ab27a6d36026d0e028fc0aef60dd9f92885b29adb5fa997b551b54c9aadbaca24fdd71a4f7b1d94337f3a3887955c108a5b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.2.0] - 2025-06-08
3
+ ## [0.3.1] - 2025-06-08
4
+
5
+ - Fix current queue being mutated in `AtomicThreadPool#<<`
6
+
7
+ ## [0.3.0] - 2025-06-08
4
8
 
5
9
  - Add `AtomicBoolean`
6
10
 
data/README.md CHANGED
@@ -155,7 +155,7 @@ results = []
155
155
 
156
156
  5.times.map do |idx|
157
157
  Thread.new do
158
- 100.times do
158
+ 25.times do
159
159
  account.deposit(idx + 1)
160
160
  sleep(0.2)
161
161
  account.deposit(idx + 2)
@@ -189,17 +189,17 @@ puts "Atomic Ruby Atomic Bank Account: #{results[2].real.round(6)} seconds"
189
189
 
190
190
  ruby version: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
191
191
  concurrent-ruby version: 1.3.5
192
- atomic-ruby version: 0.2.0
192
+ atomic-ruby version: 0.3.0
193
193
 
194
194
  Balances:
195
- Synchronized Bank Account Balance: 3600
196
- Concurrent Ruby Atomic Bank Account Balance: 3600
197
- Atomic Ruby Atomic Bank Account Balance: 3600
195
+ Synchronized Bank Account Balance: 975
196
+ Concurrent Ruby Atomic Bank Account Balance: 975
197
+ Atomic Ruby Atomic Bank Account Balance: 975
198
198
 
199
199
  Benchmark Results:
200
- Synchronized Bank Account: 20.467293 seconds
201
- Concurrent Ruby Atomic Bank Account: 20.460731 seconds
202
- Atomic Ruby Atomic Bank Account: 20.455696 seconds
200
+ Synchronized Bank Account: 5.125638 seconds
201
+ Concurrent Ruby Atomic Bank Account: 5.114936 seconds
202
+ Atomic Ruby Atomic Bank Account: 5.108171 seconds
203
203
  ```
204
204
 
205
205
  </details>
@@ -340,11 +340,11 @@ puts "Atomic Ruby Atomic Thread Pool: #{results[1].real.round(6)} seconds"
340
340
 
341
341
  ruby version: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
342
342
  concurrent-ruby version: 1.3.5
343
- atomic-ruby version: 0.2.0
343
+ atomic-ruby version: 0.3.0
344
344
 
345
345
  Benchmark Results:
346
- Concurrent Ruby Thread Pool: 5.188700 seconds
347
- Atomic Ruby Atomic Thread Pool: 4.783689 seconds
346
+ Concurrent Ruby Thread Pool: 5.136456 seconds
347
+ Atomic Ruby Atomic Thread Pool: 4.700981 seconds
348
348
  ```
349
349
 
350
350
  </details>
Binary file
@@ -27,7 +27,7 @@ module AtomicRuby
27
27
  raise InvalidWorkQueueingError, "cannot queue work during or after pool shutdown"
28
28
  end
29
29
 
30
- @queue.swap { |queue| queue << work }
30
+ @queue.swap { |current_queue| current_queue += [work] }
31
31
  true
32
32
  end
33
33
 
@@ -53,11 +53,11 @@ module AtomicRuby
53
53
  name = "AtomicRuby::AtomicThreadPool thread #{idx}"
54
54
  Thread.current.name = name
55
55
 
56
- @started_threads.swap { |count| count + 1 }
56
+ @started_threads.swap { |current_count| current_count + 1 }
57
57
 
58
58
  loop do
59
59
  work = nil
60
- @queue.swap { |queue| work = queue.last; queue[0..-2] }
60
+ @queue.swap { |current_queue| work = current_queue.last; current_queue[0..-2] }
61
61
  case work
62
62
  when Proc
63
63
  begin
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AtomicRuby
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atomic-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young