atomic-ruby 0.7.1 → 0.7.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 +4 -0
- data/README.md +2 -2
- data/lib/atomic-ruby/atomic_thread_pool.rb +3 -4
- data/lib/atomic-ruby/version.rb +1 -1
- metadata +1 -2
- data/lib/atomic-ruby/linked_list.rb +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df0115a62c1857c8f5c11cac42003d5ed1c91ec1c5b204d5b5cf093f25d5cab9
|
|
4
|
+
data.tar.gz: 67963d4c342b33e235a5cb320013388dc227d46311c80c1b19e029b4ff02bc1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e26adf803f4e798808a736eabdb86dc8d4074a71231aa2806e15f84ea5c8c6a7770cc268fb412733702fb0c540d1392e01265bf3571c3d143165f51776f72c19
|
|
7
|
+
data.tar.gz: d788e9e25c29f26050095050357ddb64b31a132bd1c9d9e13604945eec2382744a0b94e9f946d97eec6721c73fa16d83e574fc5e3e0644a3101c8b97b9b9b833
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -384,8 +384,8 @@ concurrent-ruby version: 1.3.5
|
|
|
384
384
|
atomic-ruby version: 0.7.0
|
|
385
385
|
|
|
386
386
|
Benchmark Results:
|
|
387
|
-
Concurrent Ruby Thread Pool:
|
|
388
|
-
Atomic Ruby Atomic Thread Pool:
|
|
387
|
+
Concurrent Ruby Thread Pool: 5.30284 seconds
|
|
388
|
+
Atomic Ruby Atomic Thread Pool: 5.019147 seconds
|
|
389
389
|
```
|
|
390
390
|
|
|
391
391
|
</details>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "atom"
|
|
4
|
-
require_relative "linked_list"
|
|
5
4
|
|
|
6
5
|
module AtomicRuby
|
|
7
6
|
class AtomicThreadPool
|
|
@@ -18,7 +17,7 @@ module AtomicRuby
|
|
|
18
17
|
@size = size
|
|
19
18
|
@name = name
|
|
20
19
|
|
|
21
|
-
@state = Atom.new(queue:
|
|
20
|
+
@state = Atom.new(queue: [], shutdown: false)
|
|
22
21
|
@started_threads = Atom.new(0)
|
|
23
22
|
@threads = []
|
|
24
23
|
|
|
@@ -30,7 +29,7 @@ module AtomicRuby
|
|
|
30
29
|
if current_state[:shutdown]
|
|
31
30
|
current_state
|
|
32
31
|
else
|
|
33
|
-
current_state.merge(queue: current_state[:queue]
|
|
32
|
+
current_state.merge(queue: [*current_state[:queue], work])
|
|
34
33
|
end
|
|
35
34
|
end
|
|
36
35
|
raise EnqueuedWorkAfterShutdownError if state[:shutdown]
|
|
@@ -84,7 +83,7 @@ module AtomicRuby
|
|
|
84
83
|
current_state
|
|
85
84
|
else
|
|
86
85
|
work = current_state[:queue].first
|
|
87
|
-
current_state.merge(queue: current_state[:queue].
|
|
86
|
+
current_state.merge(queue: current_state[:queue].drop(1))
|
|
88
87
|
end
|
|
89
88
|
end
|
|
90
89
|
|
data/lib/atomic-ruby/version.rb
CHANGED
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.7.
|
|
4
|
+
version: 0.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Young
|
|
@@ -29,7 +29,6 @@ files:
|
|
|
29
29
|
- lib/atomic-ruby/atomic_boolean.rb
|
|
30
30
|
- lib/atomic-ruby/atomic_count_down_latch.rb
|
|
31
31
|
- lib/atomic-ruby/atomic_thread_pool.rb
|
|
32
|
-
- lib/atomic-ruby/linked_list.rb
|
|
33
32
|
- lib/atomic-ruby/version.rb
|
|
34
33
|
homepage: https://github.com/joshuay03/atomic-ruby
|
|
35
34
|
licenses:
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module AtomicRuby
|
|
4
|
-
class LinkedList
|
|
5
|
-
Node = Data.define(:value, :next_node)
|
|
6
|
-
|
|
7
|
-
def initialize(head = nil)
|
|
8
|
-
@head = head
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def prepend(value)
|
|
12
|
-
self.class.new(Node.new(value, @head))
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def first
|
|
16
|
-
@head&.value
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def rest
|
|
20
|
-
self.class.new(@head&.next_node)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def empty?
|
|
24
|
-
@head.nil?
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def length
|
|
28
|
-
count = 0
|
|
29
|
-
current = @head
|
|
30
|
-
while current
|
|
31
|
-
count += 1
|
|
32
|
-
current = current.next_node
|
|
33
|
-
end
|
|
34
|
-
count
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|