smart_engine 0.15.0 → 0.17.0
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 +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/smart_core/engine/read_write_lock.rb +20 -10
- data/lib/smart_core/engine/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2e00e5e76c385efb45b5718cf06001da83309a1dc7e09a32c0b84131c76904
|
4
|
+
data.tar.gz: 3e6b356d9c108f423e482874556312b26af2247aea4a7f8e8150ecb9827fb936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acb16bc9be8e2c8865241cb4584a657b2172318d60bb01726f9886b591248f9e79ffb5dfe378f0a66e94cab0ccd6347c77f43237d1af043d3d83d34b4f22ce1c
|
7
|
+
data.tar.gz: 40e44b17967ade1ac69adf5109a5894836fab5b726e2b216c5df445baf6e0405b4cd6c3f1e69131cae3e2c3ee337321ff8ca7fe5c3a12abc1dc2db117f205b9a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.17.0] - 2022-10-14
|
5
|
+
### Changed
|
6
|
+
- **SmartCore::Engine::ReadWriteLock**: allow #read_sync invocations inside #write_sync;
|
7
|
+
|
8
|
+
## [0.16.0] - 2022-09-30
|
9
|
+
### Changed
|
10
|
+
- `SmartCore::Engine::ReadWriteLock` does not lock the current thread if the current thread has already acquired the lock;
|
11
|
+
|
4
12
|
## [0.15.0] - 2022-09-30
|
5
13
|
### Added
|
6
14
|
- `SmartCore::Engine::ReadWriteLock#write_owned?` - checking that write lock is owned by current thread or not;
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,7 +34,7 @@ require 'smart_core'
|
|
34
34
|
|
35
35
|
- [Global set of error types](#global-set-of-error-types)
|
36
36
|
- [Simple reentrant lock](#simple-reentrant-lock)
|
37
|
-
- [Read/Write Lock](#
|
37
|
+
- [Read/Write Lock](#readwrite-lock)
|
38
38
|
- [Cache Storage](#cache-storage)
|
39
39
|
- [Atomic thread-safe value container](#atomic-thread-safe-value-container)
|
40
40
|
- [Any Object Frozener](#any-object-frozener) (classic c-level `frozen?`/`freeze`)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# @api public
|
4
4
|
# @since 0.14.0
|
5
|
-
# @version 0.
|
5
|
+
# @version 0.17.0
|
6
6
|
class SmartCore::Engine::ReadWriteLock
|
7
7
|
# @return [void]
|
8
8
|
#
|
@@ -21,10 +21,15 @@ class SmartCore::Engine::ReadWriteLock
|
|
21
21
|
#
|
22
22
|
# @api public
|
23
23
|
# @since 0.14.0
|
24
|
+
# @version 0.17.0
|
24
25
|
def read_sync(&block)
|
25
26
|
@active_reader = true
|
26
|
-
|
27
|
-
|
27
|
+
if @write_lock.locked? && @write_lock.owned?
|
28
|
+
yield
|
29
|
+
else
|
30
|
+
while @write_lock.locked? do; end
|
31
|
+
yield
|
32
|
+
end
|
28
33
|
ensure
|
29
34
|
@active_reader = false
|
30
35
|
end
|
@@ -42,14 +47,19 @@ class SmartCore::Engine::ReadWriteLock
|
|
42
47
|
#
|
43
48
|
# @api public
|
44
49
|
# @since 0.14.0
|
50
|
+
# @version 0.16.0
|
45
51
|
def write_sync(&block)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
if @write_lock.owned?
|
53
|
+
yield
|
54
|
+
else
|
55
|
+
while @active_reader do; end
|
56
|
+
@write_lock.synchronize do
|
57
|
+
@active_reader = true
|
58
|
+
begin
|
59
|
+
yield
|
60
|
+
ensure
|
61
|
+
@active_reader = false
|
62
|
+
end
|
53
63
|
end
|
54
64
|
end
|
55
65
|
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.17.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-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|