smart_engine 0.3.0 → 0.4.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: 6541e8d5473adec2d2694952dc216c597868a1d18ec7c87f31d12f3d9bf0ae16
4
- data.tar.gz: 4f1edf67c3389b91202778926243ff99c52280bad57a5a833888239a7f5e23cf
3
+ metadata.gz: 9411f71246102241e6508d2aeda65cb13e988630379226451f8ade8a861244aa
4
+ data.tar.gz: b9a9b194acbb23a7bc0a51446b1b06f3272974a214d92d9cd71bd922bca823c1
5
5
  SHA512:
6
- metadata.gz: 71b7cc9b85346c7ed17281c0f50ddf5026cc6ad0b135087a1915fee6620be85019a1bdd0e79ec15ee5a14c8da207da84322ef297917ad1eb1956ec7b85b1b648
7
- data.tar.gz: d7a4fabcc86cb65ef4309d99581d8a3f2c215164f7a405a0d6bf5ac5c0deeed5f6320c3b83530ccc6ef5b67bfe70d3d765289ae574b08dd3cf97428b6d4308b6
6
+ metadata.gz: b4bd7b3d0d0002e88f2d1e0d1a8bfb8a9bc71d76454c2d7e41e4cb37c1f277b8f1f7423331323ebb8dac2bedf5fafc498d98578dbd626918b8570928ba0d614a
7
+ data.tar.gz: 5d861333ea8b814b3c659a97801066768e5f0569ea38f973320276e64383aba185490570c26c27329be0e4864b2cfd518f8b226b33789e63ae089af4d2354826
@@ -1,7 +1,11 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.3.0] -202-01-17
4
+ ## [0.4.0] - 2020-01-19
5
+ ### Added
6
+ - `SmartCore::Engine::Lock` - simple reentrant-based locking primitive;
7
+
8
+ ## [0.3.0] - 2020-01-17
5
9
  ### Added
6
10
  - Global error type `SmartCore::NameError` inherited from `::NameError`;
7
11
 
data/README.md CHANGED
@@ -22,11 +22,26 @@ require 'smart_core'
22
22
 
23
23
  ## Technologies
24
24
 
25
- - **Global set of error types**:
26
- - `SmartCore::Error` (inherited from `::StandardError`);
27
- - `SmartCore::ArgumentError` (inherited from `::ArgumentError`);
28
- - `SmartCore::FrozenError` (inherited from `::FrozenError`);
29
- - `SmartCore::NameError` (inherited from `::NameError`);
25
+ - [Global set of error types](#global-set-of-error-types)
26
+ - [Simple reenternant lock](#simple-reenternant-lock)
27
+
28
+ ---
29
+
30
+ ### Global set of error types
31
+
32
+ - `SmartCore::Error` (inherited from `::StandardError`);
33
+ - `SmartCore::ArgumentError` (inherited from `::ArgumentError`);
34
+ - `SmartCore::FrozenError` (inherited from `::FrozenError`);
35
+ - `SmartCore::NameError` (inherited from `::NameError`);
36
+
37
+ ---
38
+
39
+ ### Simple reenternant lock
40
+
41
+ ```ruby
42
+ lock = SmartCore::Engine::Lock.new
43
+ lock.synchronize { your_code }
44
+ ```
30
45
 
31
46
  ---
32
47
 
@@ -4,4 +4,5 @@
4
4
  # @since 0.1.0
5
5
  module SmartCore::Engine
6
6
  require_relative 'engine/version'
7
+ require_relative 'engine/lock'
7
8
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.4.0
5
+ class SmartCore::Engine::Lock
6
+ # @return [void]
7
+ #
8
+ # @api public
9
+ # @since 0.4.0
10
+ def initialize
11
+ @lock = Mutex.new
12
+ end
13
+
14
+ # @param block [Block]
15
+ # @return [Any]
16
+ #
17
+ # @api public
18
+ # @since 0.4.0
19
+ def synchronize(&block)
20
+ @lock.owned? ? yield : @lock.synchronize(&block)
21
+ end
22
+ end
@@ -6,7 +6,7 @@ module SmartCore
6
6
  #
7
7
  # @api public
8
8
  # @since 0.1.0
9
- # @version 0.3.0
10
- VERSION = '0.3.0'
9
+ # @version 0.4.0
10
+ VERSION = '0.4.0'
11
11
  end
12
12
  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.3.0
4
+ version: 0.4.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-01-16 00:00:00.000000000 Z
11
+ date: 2020-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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/lock.rb
122
123
  - lib/smart_core/engine/version.rb
123
124
  - lib/smart_core/errors.rb
124
125
  - smart_engine.gemspec