smart_container 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 929c6fcba625ebb836b753d4563082ea2d0aa793abbf840ed97fe6f209a0c7b0
4
- data.tar.gz: b9cf58d9fc718aff98847e74f986b86da7984c3537f5258a37a2c67f9af611e8
3
+ metadata.gz: 83dabfca5288c9506f90616e0e361839e9f57e5becb033337b194369e37b2b3e
4
+ data.tar.gz: 49692a8df8837154e72374079a4f1c37a423a58da4fa26f61cae0ac5075aa49d
5
5
  SHA512:
6
- metadata.gz: 93e6062a36edf2f06d37132dc53b55c87f5f0aac277eafec6a17572ff60f73e0c164ed4fae53ee5333c10556e605e8d4c9c29b935406f7a9dceb0280e7bfa4df
7
- data.tar.gz: a653c4ded2e96d9fe4f42292eabe0467ad1cfe3a2633aa3bd4f77506d69f65c0a32703ecffb6875eb5d3de9d3e34592fdebc95c50417257c5a864273b9ae116c
6
+ metadata.gz: 99bb75dae1cda18661d918c3e3db4672f958baf892f26a007dd8cdf34d8b841c31fbdbf00d5db06f4641bbcf980b0dc02ec2cc60a6bf73c96bbb7914c2c8bf03
7
+ data.tar.gz: eed818ffd4c20aaddd8b0dd3335ff49f0e1d824f1f319517805a30b0753c802e237487e9343684e5802fc8a5decadde7e2382badd9a8261a7d3c51d694531e4b
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.11.0] - 2022-10-14
5
+ ### Fixed
6
+ - Unreachable `SmartCore::Container::ArbitraryLock` (rewritten with `SmartCore::Engine::ReadWriteLock`);
7
+
4
8
  ## [0.10.0] - 2022-10-14
5
9
  ### Changed
6
10
  - Simple `Mutex`-based locks was replaced with `SmartCore::Engine::ReadWriteLock` in order to decrease
7
- context switching during method resolving inside RubyVM (to reduce thread locks when it is not necessary);
11
+ context switching during method resolving inside RubyVM (reduced thread lock acquire count);
8
12
  - Development progress:
9
13
  - Minimal ruby version - **2.5**;
10
14
  - Updated development dependencies;
data/Gemfile.lock CHANGED
@@ -19,38 +19,25 @@ GEM
19
19
  rubocop-rake (= 0.6.0)
20
20
  rubocop-rspec (= 2.13.2)
21
21
  ast (2.4.2)
22
- backport (1.2.0)
23
- benchmark (0.2.0)
24
22
  coderay (1.1.3)
25
23
  concurrent-ruby (1.1.10)
26
24
  diff-lcs (1.5.0)
27
25
  docile (1.4.0)
28
- e2mmap (0.1.0)
29
26
  i18n (1.12.0)
30
27
  concurrent-ruby (~> 1.0)
31
- jaro_winkler (1.5.4)
32
28
  json (2.6.2)
33
- kramdown (2.4.0)
34
- rexml
35
- kramdown-parser-gfm (1.1.0)
36
- kramdown (~> 2.0)
37
29
  method_source (1.0.0)
38
30
  minitest (5.16.3)
39
- nokogiri (1.13.8-arm64-darwin)
40
- racc (~> 1.4)
41
31
  parallel (1.22.1)
42
32
  parser (3.1.2.1)
43
33
  ast (~> 2.4.1)
44
34
  pry (0.14.1)
45
35
  coderay (~> 1.1)
46
36
  method_source (~> 1.0)
47
- racc (1.6.0)
48
37
  rack (3.0.0)
49
38
  rainbow (3.1.1)
50
39
  rake (13.0.6)
51
40
  regexp_parser (2.6.0)
52
- reverse_markdown (2.1.1)
53
- nokogiri
54
41
  rexml (3.2.5)
55
42
  rspec (3.11.0)
56
43
  rspec-core (~> 3.11.0)
@@ -96,32 +83,13 @@ GEM
96
83
  simplecov-html (0.12.3)
97
84
  simplecov_json_formatter (0.1.4)
98
85
  smart_engine (0.17.0)
99
- solargraph (0.47.2)
100
- backport (~> 1.2)
101
- benchmark
102
- bundler (>= 1.17.2)
103
- diff-lcs (~> 1.4)
104
- e2mmap
105
- jaro_winkler (~> 1.5)
106
- kramdown (~> 2.3)
107
- kramdown-parser-gfm (~> 1.1)
108
- parser (~> 3.0)
109
- reverse_markdown (>= 1.0.5, < 3)
110
- rubocop (>= 0.52)
111
- thor (~> 1.0)
112
- tilt (~> 2.0)
113
- yard (~> 0.9, >= 0.9.24)
114
- thor (1.2.1)
115
- tilt (2.0.11)
116
86
  tzinfo (2.0.5)
117
87
  concurrent-ruby (~> 1.0)
118
88
  unicode-display_width (2.3.0)
119
- webrick (1.7.0)
120
- yard (0.9.28)
121
- webrick (~> 1.7.0)
122
89
 
123
90
  PLATFORMS
124
91
  arm64-darwin-21
92
+ x86_64-darwin-20
125
93
 
126
94
  DEPENDENCIES
127
95
  armitage-rubocop (~> 1.36)
@@ -131,7 +99,6 @@ DEPENDENCIES
131
99
  rspec (~> 3.11)
132
100
  simplecov (~> 0.21)
133
101
  smart_container!
134
- solargraph (~> 0.47)
135
102
 
136
103
  BUNDLED WITH
137
104
  2.3.23
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.1.0
5
+ # @version 0.11.0
5
6
  class SmartCore::Container::DefinitionDSL::CommandSet
6
7
  # @since 0.1.0
7
8
  include Enumerable
@@ -16,9 +17,10 @@ class SmartCore::Container::DefinitionDSL::CommandSet
16
17
  #
17
18
  # @api private
18
19
  # @since 0.1.0
20
+ # @version 0.11.0
19
21
  def initialize
20
22
  @commands = []
21
- @access_lock = SmartCore::Container::ArbitraryLock.new
23
+ @lock = SmartCore::Engine::ReadWriteLock.new
22
24
  end
23
25
 
24
26
  # @param [SmartCore::Container::DefinitionDSL::Commands::Base]
@@ -26,8 +28,9 @@ class SmartCore::Container::DefinitionDSL::CommandSet
26
28
  #
27
29
  # @api private
28
30
  # @since 0.1.0
31
+ # @version 0.11.0
29
32
  def add_command(command)
30
- thread_safe { commands << command }
33
+ @lock.write_sync { commands << command }
31
34
  end
32
35
  alias_method :<<, :add_command
33
36
 
@@ -36,8 +39,9 @@ class SmartCore::Container::DefinitionDSL::CommandSet
36
39
  #
37
40
  # @api private
38
41
  # @since 0.1.0
42
+ # @version 0.11.0
39
43
  def each(&block)
40
- thread_safe { block_given? ? commands.each(&block) : commands.each }
44
+ @lock.read_sync { block_given? ? commands.each(&block) : commands.each }
41
45
  end
42
46
 
43
47
  # @param command_set [SmartCore::Container::DefinitionDSL::CommandSet]
@@ -48,8 +52,9 @@ class SmartCore::Container::DefinitionDSL::CommandSet
48
52
  #
49
53
  # @api private
50
54
  # @since 0.1.0
55
+ # @version 0.11.0
51
56
  def concat(command_set, &concat_condition)
52
- thread_safe do
57
+ @lock.read_sync do
53
58
  if block_given?
54
59
  command_set.dup.each { |command| (commands << command) if yield(command) }
55
60
  else
@@ -64,8 +69,9 @@ class SmartCore::Container::DefinitionDSL::CommandSet
64
69
  #
65
70
  # @api private
66
71
  # @since 0.1.0
72
+ # @version 0.11.0
67
73
  def dup
68
- thread_safe do
74
+ @lock.read_sync do
69
75
  self.class.new.tap do |duplicate|
70
76
  commands.each do |command|
71
77
  duplicate.add_command(command.dup)
@@ -82,6 +88,6 @@ class SmartCore::Container::DefinitionDSL::CommandSet
82
88
  # @api private
83
89
  # @since 0.1.0
84
90
  def thread_safe(&block)
85
- @access_lock.thread_safe(&block)
91
+ @lock.thread_safe(&block)
86
92
  end
87
93
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.8.0
5
+ # @version 0.11.0
5
6
  class SmartCore::Container::DependencyWatcher
6
7
  require_relative 'dependency_watcher/observer'
7
8
 
@@ -10,10 +11,11 @@ class SmartCore::Container::DependencyWatcher
10
11
  #
11
12
  # @api private
12
13
  # @since 0.8.0
14
+ # @version 0.11.0
13
15
  def initialize(container)
14
16
  @container = container
15
17
  @observers = Hash.new { |h, k| h[k] = [] }
16
- @access_lock = SmartCore::Container::ArbitraryLock.new
18
+ @lock = SmartCore::Engine::ReadWriteLock.new
17
19
  end
18
20
 
19
21
  # @param entity_path [String, Symbol]
@@ -21,8 +23,9 @@ class SmartCore::Container::DependencyWatcher
21
23
  #
22
24
  # @api private
23
25
  # @since 0.8.0
26
+ # @version 0.11.0
24
27
  def notify(entity_path)
25
- thread_safe { notify_listeners(entity_path) }
28
+ @lock.read_sync { notify_listeners(entity_path) }
26
29
  end
27
30
 
28
31
  # @param entity_path [String, Symbol]
@@ -31,8 +34,9 @@ class SmartCore::Container::DependencyWatcher
31
34
  #
32
35
  # @api private
33
36
  # @since 0.8.0
37
+ # @version 0.11.0
34
38
  def watch(entity_path, &observer) # TODO: support for pattern-based pathes
35
- thread_safe { listen(entity_path, observer) }
39
+ @lock.write_sync { listen(entity_path, observer) }
36
40
  end
37
41
 
38
42
  # @param observer [SmartCore::Container::DependencyWatcher::Observer]
@@ -40,8 +44,9 @@ class SmartCore::Container::DependencyWatcher
40
44
  #
41
45
  # @api private
42
46
  # @since 0.8.0
47
+ # @version 0.11.0
43
48
  def unwatch(observer)
44
- thread_safe { remove_listener(observer) }
49
+ @lock.write_sync { remove_listener(observer) }
45
50
  end
46
51
 
47
52
  # @param entity_path [String, Symbol, NilClass]
@@ -49,8 +54,9 @@ class SmartCore::Container::DependencyWatcher
49
54
  #
50
55
  # @api private
51
56
  # @since 0.8.0
57
+ # @version 0.11.0
52
58
  def clear_listeners(entity_path = nil) # TODO: support for pattern-based pathes
53
- thread_safe { remove_listeners(entity_path) }
59
+ @lock.write_sync { remove_listeners(entity_path) }
54
60
  end
55
61
 
56
62
  private
@@ -139,13 +145,4 @@ class SmartCore::Container::DependencyWatcher
139
145
  def indifferently_accessable_path(entity_path)
140
146
  SmartCore::Container::KeyGuard.indifferently_accessable_key(entity_path)
141
147
  end
142
-
143
- # @param block [Block]
144
- # @return [Any]
145
- #
146
- # @api private
147
- # @since 0.8.0
148
- def thread_safe(&block)
149
- @access_lock.thread_safe(&block)
150
- end
151
148
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api public
4
4
  # @since 0.1.0
5
+ # @version 0.11.0
5
6
  module SmartCore::Container::Mixin
6
7
  class << self
7
8
  # @param base_klass [Class]
@@ -9,9 +10,10 @@ module SmartCore::Container::Mixin
9
10
  #
10
11
  # @api private
11
12
  # @since 0.1.0
13
+ # @version 0.11.0
12
14
  def included(base_klass)
13
15
  # rubocop:disable Layout/LineLength
14
- base_klass.instance_variable_set(:@__smart_core_container_access_lock__, SmartCore::Container::ArbitraryLock.new)
16
+ base_klass.instance_variable_set(:@__smart_core_container_access_lock__, SmartCore::Engine::ReadWriteLock.new)
15
17
  base_klass.instance_variable_set(:@__smart_core_container_klass__, Class.new(SmartCore::Container))
16
18
  base_klass.instance_variable_set(:@__smart_core_container__, nil)
17
19
  # rubocop:enable Layout/LineLength
@@ -24,17 +26,19 @@ module SmartCore::Container::Mixin
24
26
 
25
27
  # @api private
26
28
  # @since 0.1.0
29
+ # @version 0.11.0
27
30
  module ClassInheritance
28
31
  # @param child_klass [CLass]
29
32
  # @return [void]
30
33
  #
31
34
  # @api private
32
35
  # @since 0.1.0
36
+ # @version 0.11.0
33
37
  def inherited(child_klass)
34
38
  inherited_container_klass = Class.new(@__smart_core_container_klass__)
35
39
 
36
40
  # rubocop:disable Layout/LineLength
37
- child_klass.instance_variable_set(:@__smart_core_container_access_lock__, SmartCore::Container::ArbitraryLock.new)
41
+ child_klass.instance_variable_set(:@__smart_core_container_access_lock__, SmartCore::Engine::ReadWriteLock.new)
38
42
  child_klass.instance_variable_set(:@__smart_core_container_klass__, inherited_container_klass)
39
43
  child_klass.instance_variable_set(:@__smart_core_container__, nil)
40
44
  # rubocop:enable Layout/LineLength
@@ -44,6 +48,7 @@ module SmartCore::Container::Mixin
44
48
 
45
49
  # @api private
46
50
  # @since 0.1.0
51
+ # @version 0.11.0
47
52
  module ClassMethods
48
53
  # @param freeze_state [Boolean]
49
54
  # @param block [Proc]
@@ -51,8 +56,9 @@ module SmartCore::Container::Mixin
51
56
  #
52
57
  # @api public
53
58
  # @since 0.1.0
59
+ # @version 0.11.0
54
60
  def dependencies(freeze_state: false, &block)
55
- @__smart_core_container_access_lock__.thread_safe do
61
+ @__smart_core_container_access_lock__.write_sync do
56
62
  @__smart_core_container_klass__.instance_eval(&block) if block_given?
57
63
  @__smart_core_container_klass__.instance_eval { freeze_state! } if freeze_state
58
64
  end
@@ -62,8 +68,9 @@ module SmartCore::Container::Mixin
62
68
  #
63
69
  # @api public
64
70
  # @since 0.1.0
71
+ # @version 0.11.0
65
72
  def container
66
- @__smart_core_container_access_lock__.thread_safe do
73
+ @__smart_core_container_access_lock__.read_sync do
67
74
  @__smart_core_container__ ||= @__smart_core_container_klass__.new
68
75
  end
69
76
  end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.10.0
10
- VERSION = '0.10.0'
9
+ # @version 0.11.0
10
+ VERSION = '0.11.0'
11
11
  end
12
12
  end
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency 'smart_engine', '~> 0.17'
31
31
 
32
- spec.add_development_dependency 'solargraph', '~> 0.47'
33
32
  spec.add_development_dependency 'bundler', '~> 2.3'
34
33
  spec.add_development_dependency 'rake', '~> 13.0'
35
34
  spec.add_development_dependency 'rspec', '~> 3.11'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.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: 2022-10-13 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_engine
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.17'
27
- - !ruby/object:Gem::Dependency
28
- name: solargraph
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.47'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.47'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -200,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
186
  - !ruby/object:Gem::Version
201
187
  version: '0'
202
188
  requirements: []
203
- rubygems_version: 3.3.11
189
+ rubygems_version: 3.3.7
204
190
  signing_key:
205
191
  specification_version: 4
206
192
  summary: IoC/DI Container