cli-ui 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/ui/stdout_router.rb +2 -2
- data/lib/cli/ui/version.rb +1 -1
- data/vendor/reentrant_mutex.rb +42 -39
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09d2f934743c06d2682e5edd21001d81bc80f559015310483fa1d88571c05bcb'
|
4
|
+
data.tar.gz: 47abf444dffe2a80da451889dceeaf9056e9794e585d7d2074d222bbf943aea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ac5bc5856d536eb2fd70a77f0c1df9af493a2b8b3395249f47eaae9f0013b360ae4769828fb476b3b7e2d9fe74f73243106fe3c3c96ab476a603b93b8dc9a95
|
7
|
+
data.tar.gz: b65d111cd17a436e6a5d317ab04fd86e72bfcc9dd05f440fb7db50a5b48eaa2e20c89f35aedbf708b099ad3634ebb5a9fb8be7366828ce382aa8998a69c0284a
|
data/lib/cli/ui/stdout_router.rb
CHANGED
@@ -92,7 +92,7 @@ module CLI
|
|
92
92
|
extend T::Sig
|
93
93
|
|
94
94
|
@capture_mutex = Mutex.new
|
95
|
-
@stdin_mutex = ReentrantMutex.new
|
95
|
+
@stdin_mutex = CLI::UI::ReentrantMutex.new
|
96
96
|
@active_captures = 0
|
97
97
|
@saved_stdin = nil
|
98
98
|
|
@@ -262,7 +262,7 @@ module CLI
|
|
262
262
|
sig { params(stream: IO).void }
|
263
263
|
def initialize(stream)
|
264
264
|
@stream = stream
|
265
|
-
@m = ReentrantMutex.new
|
265
|
+
@m = CLI::UI::ReentrantMutex.new
|
266
266
|
end
|
267
267
|
|
268
268
|
sig { type_parameters(:T).params(block: T.proc.returns(T.type_parameter(:T))).returns(T.type_parameter(:T)) }
|
data/lib/cli/ui/version.rb
CHANGED
data/vendor/reentrant_mutex.rb
CHANGED
@@ -22,54 +22,57 @@
|
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
24
|
# Sourced from https://github.com/dotboris/reentrant_mutex
|
25
|
+
module CLI
|
26
|
+
module UI
|
27
|
+
class ReentrantMutex < Mutex
|
28
|
+
def initialize
|
29
|
+
@count_mutex = Mutex.new
|
30
|
+
@counts = Hash.new(0)
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
@count_mutex = Mutex.new
|
29
|
-
@counts = Hash.new(0)
|
32
|
+
super
|
33
|
+
end
|
30
34
|
|
31
|
-
|
32
|
-
|
35
|
+
def synchronize
|
36
|
+
raise ThreadError, 'Must be called with a block' unless block_given?
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
begin
|
39
|
+
lock
|
40
|
+
yield
|
41
|
+
ensure
|
42
|
+
unlock
|
43
|
+
end
|
44
|
+
end
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
unlock
|
42
|
-
end
|
43
|
-
end
|
46
|
+
def lock
|
47
|
+
c = increase_count Thread.current
|
48
|
+
super if c <= 1
|
49
|
+
end
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
def unlock
|
52
|
+
c = decrease_count Thread.current
|
53
|
+
if c <= 0
|
54
|
+
super
|
55
|
+
delete_count Thread.current
|
56
|
+
end
|
57
|
+
end
|
49
58
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
super
|
54
|
-
delete_count Thread.current
|
55
|
-
end
|
56
|
-
end
|
59
|
+
def count
|
60
|
+
@count_mutex.synchronize { @counts[Thread.current] }
|
61
|
+
end
|
57
62
|
|
58
|
-
|
59
|
-
@count_mutex.synchronize { @counts[Thread.current] }
|
60
|
-
end
|
63
|
+
private
|
61
64
|
|
62
|
-
|
65
|
+
def increase_count(thread)
|
66
|
+
@count_mutex.synchronize { @counts[thread] += 1 }
|
67
|
+
end
|
63
68
|
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
def decrease_count(thread)
|
70
|
+
@count_mutex.synchronize { @counts[thread] -= 1 }
|
71
|
+
end
|
67
72
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
def delete_count(thread)
|
73
|
-
@count_mutex.synchronize { @counts.delete(thread) }
|
73
|
+
def delete_count(thread)
|
74
|
+
@count_mutex.synchronize { @counts.delete(thread) }
|
75
|
+
end
|
76
|
+
end
|
74
77
|
end
|
75
78
|
end
|