smart_engine 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +30 -27
- data/README.md +17 -0
- data/lib/smart_core/engine.rb +1 -0
- data/lib/smart_core/engine/atom.rb +43 -0
- data/lib/smart_core/engine/version.rb +2 -2
- data/smart_engine.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb49309ce61e395a7073af81c275aabdb9adbcf8d8b7d953da30aa87bafa7f20
|
4
|
+
data.tar.gz: 3e08590d5bce668b39ee3ea8893de436154dab189a6b528d1ca68156abbcb5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe721dc23e1d34a4fac5a37e49e9909758d80605f6e8bdff145e3bf532439a26d192941638896c1d7da4fdec0c8dc9f879fadab4dae4b1a341a5ded4999cba26
|
7
|
+
data.tar.gz: f99856596971bb98fa521e1ee77a777f17bc7c7a6541477aa243f625e58e8f21d7f9a6d5bbadd51e38241cd05cb37b0e67a229bc3a3fe2459a3e2ae30a23ed85
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.7.0] - 2020-07-03
|
5
|
+
### Added
|
6
|
+
- Atomic threadsafe value container (`SmartCore::Engine::Atom`);
|
7
|
+
|
4
8
|
## [0.6.0] - 2020-05-03
|
5
9
|
### Added
|
6
10
|
- Inline rescue pipe (`SmartCore::Engine::RescueExt.inline_rescue_pipe`);
|
data/Gemfile.lock
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smart_engine (0.
|
4
|
+
smart_engine (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (6.0.
|
9
|
+
activesupport (6.0.3.2)
|
10
10
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
11
|
i18n (>= 0.7, < 2)
|
12
12
|
minitest (~> 5.1)
|
13
13
|
tzinfo (~> 1.1)
|
14
|
-
zeitwerk (~> 2.2)
|
15
|
-
armitage-rubocop (0.
|
16
|
-
rubocop (= 0.
|
17
|
-
rubocop-performance (= 1.
|
18
|
-
rubocop-rails (= 2.
|
14
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
15
|
+
armitage-rubocop (0.85.1)
|
16
|
+
rubocop (= 0.85.1)
|
17
|
+
rubocop-performance (= 1.6.1)
|
18
|
+
rubocop-rails (= 2.6.0)
|
19
19
|
rubocop-rake (= 0.5.1)
|
20
|
-
rubocop-rspec (= 1.
|
21
|
-
ast (2.4.
|
20
|
+
rubocop-rspec (= 1.40.0)
|
21
|
+
ast (2.4.1)
|
22
22
|
coderay (1.1.2)
|
23
23
|
concurrent-ruby (1.1.6)
|
24
|
-
diff-lcs (1.
|
24
|
+
diff-lcs (1.4.4)
|
25
25
|
docile (1.3.2)
|
26
|
-
i18n (1.8.
|
26
|
+
i18n (1.8.3)
|
27
27
|
concurrent-ruby (~> 1.0)
|
28
|
-
jaro_winkler (1.5.4)
|
29
28
|
method_source (1.0.0)
|
30
|
-
minitest (5.14.
|
31
|
-
parallel (1.19.
|
32
|
-
parser (2.7.1.
|
33
|
-
ast (~> 2.4.
|
29
|
+
minitest (5.14.1)
|
30
|
+
parallel (1.19.2)
|
31
|
+
parser (2.7.1.4)
|
32
|
+
ast (~> 2.4.1)
|
34
33
|
pry (0.13.1)
|
35
34
|
coderay (~> 1.1)
|
36
35
|
method_source (~> 1.0)
|
37
|
-
rack (2.2.
|
36
|
+
rack (2.2.3)
|
38
37
|
rainbow (3.0.0)
|
39
38
|
rake (13.0.1)
|
39
|
+
regexp_parser (1.7.1)
|
40
40
|
rexml (3.2.4)
|
41
41
|
rspec (3.9.0)
|
42
42
|
rspec-core (~> 3.9.0)
|
@@ -44,30 +44,33 @@ GEM
|
|
44
44
|
rspec-mocks (~> 3.9.0)
|
45
45
|
rspec-core (3.9.2)
|
46
46
|
rspec-support (~> 3.9.3)
|
47
|
-
rspec-expectations (3.9.
|
47
|
+
rspec-expectations (3.9.2)
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
49
|
rspec-support (~> 3.9.0)
|
50
50
|
rspec-mocks (3.9.1)
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
52
|
rspec-support (~> 3.9.0)
|
53
53
|
rspec-support (3.9.3)
|
54
|
-
rubocop (0.
|
55
|
-
jaro_winkler (~> 1.5.1)
|
54
|
+
rubocop (0.85.1)
|
56
55
|
parallel (~> 1.10)
|
57
56
|
parser (>= 2.7.0.1)
|
58
57
|
rainbow (>= 2.2.2, < 4.0)
|
58
|
+
regexp_parser (>= 1.7)
|
59
59
|
rexml
|
60
|
+
rubocop-ast (>= 0.0.3)
|
60
61
|
ruby-progressbar (~> 1.7)
|
61
62
|
unicode-display_width (>= 1.4.0, < 2.0)
|
62
|
-
rubocop-
|
63
|
+
rubocop-ast (0.1.0)
|
64
|
+
parser (>= 2.7.0.1)
|
65
|
+
rubocop-performance (1.6.1)
|
63
66
|
rubocop (>= 0.71.0)
|
64
|
-
rubocop-rails (2.
|
65
|
-
activesupport
|
67
|
+
rubocop-rails (2.6.0)
|
68
|
+
activesupport (>= 4.2.0)
|
66
69
|
rack (>= 1.1)
|
67
|
-
rubocop (>= 0.
|
70
|
+
rubocop (>= 0.82.0)
|
68
71
|
rubocop-rake (0.5.1)
|
69
72
|
rubocop
|
70
|
-
rubocop-rspec (1.
|
73
|
+
rubocop-rspec (1.40.0)
|
71
74
|
rubocop (>= 0.68.1)
|
72
75
|
ruby-progressbar (1.10.1)
|
73
76
|
simplecov (0.18.5)
|
@@ -78,13 +81,13 @@ GEM
|
|
78
81
|
tzinfo (1.2.7)
|
79
82
|
thread_safe (~> 0.1)
|
80
83
|
unicode-display_width (1.7.0)
|
81
|
-
zeitwerk (2.3.
|
84
|
+
zeitwerk (2.3.1)
|
82
85
|
|
83
86
|
PLATFORMS
|
84
87
|
ruby
|
85
88
|
|
86
89
|
DEPENDENCIES
|
87
|
-
armitage-rubocop (~> 0.
|
90
|
+
armitage-rubocop (~> 0.85)
|
88
91
|
bundler (~> 2.1)
|
89
92
|
pry (~> 0.13)
|
90
93
|
rake (~> 13.0)
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ require 'smart_core'
|
|
24
24
|
|
25
25
|
- [Global set of error types](#global-set-of-error-types)
|
26
26
|
- [Simple reentrant lock](#simple-reentrant-lock)
|
27
|
+
- [Atomic thread-safe value container](#atomic-thread-safe-value-container)
|
27
28
|
- [Inline rescue pipe](#inline-rescue-pipe)
|
28
29
|
|
29
30
|
---
|
@@ -47,6 +48,22 @@ lock.synchronize { your_code }
|
|
47
48
|
|
48
49
|
---
|
49
50
|
|
51
|
+
### Atomic thread-safe value container
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
atom = SmartCore::Engine::Atom.new # initial value - nil
|
55
|
+
atom.value # => nil
|
56
|
+
# --- or ---
|
57
|
+
atom = SmartCore::Engine::Atom.new(7) # initial value - 7
|
58
|
+
atom.value # => 7
|
59
|
+
|
60
|
+
# set new value (thread-safely)
|
61
|
+
atom.swap { |original_value| original_value * 2 }
|
62
|
+
atom.value # => 14
|
63
|
+
```
|
64
|
+
|
65
|
+
---
|
66
|
+
|
50
67
|
### Inline rescue pipe
|
51
68
|
|
52
69
|
- works with an array of proc objects;
|
data/lib/smart_core/engine.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @api public
|
4
|
+
# @since 0.7.0
|
5
|
+
class SmartCore::Engine::Atom
|
6
|
+
# @param initial_value [Any]
|
7
|
+
# @return [void]
|
8
|
+
#
|
9
|
+
# @api private
|
10
|
+
# @since 0.7.0
|
11
|
+
def initialize(initial_value = nil)
|
12
|
+
@value = initial_value
|
13
|
+
@barrier = SmartCore::Engine::Lock.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Any]
|
17
|
+
#
|
18
|
+
# @api public
|
19
|
+
# @since 0.7.0
|
20
|
+
def value
|
21
|
+
with_barrier { @value }
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param block [Block]
|
25
|
+
# @return [Any]
|
26
|
+
#
|
27
|
+
# @api public
|
28
|
+
# @since 0.7.0
|
29
|
+
def swap(&block)
|
30
|
+
with_barrier { @value = yield(@value) }
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# @param block [Block]
|
36
|
+
# @return [Any]
|
37
|
+
#
|
38
|
+
# @api private
|
39
|
+
# @since 0.1.0
|
40
|
+
def with_barrier(&block)
|
41
|
+
@barrier.synchronize(&block)
|
42
|
+
end
|
43
|
+
end
|
data/smart_engine.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0'
|
39
39
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
40
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 0.
|
40
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 0.85'
|
41
41
|
spec.add_development_dependency 'simplecov', '~> 0.18'
|
42
42
|
spec.add_development_dependency 'pry', '~> 0.13'
|
43
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.85'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.85'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- bin/setup
|
120
120
|
- lib/smart_core.rb
|
121
121
|
- lib/smart_core/engine.rb
|
122
|
+
- lib/smart_core/engine/atom.rb
|
122
123
|
- lib/smart_core/engine/lock.rb
|
123
124
|
- lib/smart_core/engine/rescue_ext.rb
|
124
125
|
- lib/smart_core/engine/version.rb
|