quack_concurrency 0.0.0 → 0.0.1
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/LICENSE +21 -0
- data/README.md +2 -0
- data/test/test.rb +97 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ced3c77423c57792ac57dc44069cb0351e7748c
|
4
|
+
data.tar.gz: ad10b488d8f181de7eb70a8360fba3469053edc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8a971447fec19075e50479653285b5c7a65348a01f9107fa27b3d2b530ee3210b1334ef4c5f26190739532a83442ba2f38fc6945b2d509b5c80cce7a9e5b87
|
7
|
+
data.tar.gz: 23c46a5b6c6d6f3ecfe71e8c7edf28e8068eec4883a1bb5817e85f60be878fbe75dcefc1e6f6019182b2d1244e78f8b7db3113df5162f6381f320902c662ddd0
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Rob Fors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/test/test.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
require_relative "../lib/quack_concurrency.rb"
|
4
|
+
|
5
|
+
Thread.abort_on_exception = true
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
puts 'test ConditionVariable'
|
10
|
+
m = Mutex.new
|
11
|
+
c = QuackConcurrency::ConditionVariable.new
|
12
|
+
|
13
|
+
t = []
|
14
|
+
3.times do
|
15
|
+
t << Thread.new do
|
16
|
+
m.synchronize do
|
17
|
+
c.wait(m)
|
18
|
+
print '.'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
4.times do
|
24
|
+
sleep 1
|
25
|
+
c.signal
|
26
|
+
end
|
27
|
+
|
28
|
+
t.each(&:join)
|
29
|
+
puts
|
30
|
+
|
31
|
+
|
32
|
+
puts 'test ConditionVariable'
|
33
|
+
w = QuackConcurrency::Waiter.new
|
34
|
+
|
35
|
+
t = []
|
36
|
+
3.times do
|
37
|
+
t << Thread.new do
|
38
|
+
w.wait
|
39
|
+
print '.'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
4.times do
|
44
|
+
sleep 1
|
45
|
+
w.resume
|
46
|
+
end
|
47
|
+
|
48
|
+
t.each(&:join)
|
49
|
+
puts
|
50
|
+
|
51
|
+
|
52
|
+
puts 'test ReentrantMutex'
|
53
|
+
r = QuackConcurrency::ReentrantMutex.new
|
54
|
+
|
55
|
+
t = []
|
56
|
+
3.times do
|
57
|
+
t << Thread.new do
|
58
|
+
r.lock
|
59
|
+
r.lock
|
60
|
+
r.lock
|
61
|
+
sleep 1
|
62
|
+
r.unlock
|
63
|
+
r.unlock
|
64
|
+
r.unlock
|
65
|
+
begin
|
66
|
+
r.unlock
|
67
|
+
rescue
|
68
|
+
else
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
print '.'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
t.each(&:join)
|
76
|
+
puts
|
77
|
+
|
78
|
+
|
79
|
+
puts 'test Semaphore'
|
80
|
+
s = QuackConcurrency::Semaphore.new(2)
|
81
|
+
|
82
|
+
t = []
|
83
|
+
4.times do
|
84
|
+
t << Thread.new do
|
85
|
+
s.acquire
|
86
|
+
print '.'
|
87
|
+
sleep 1
|
88
|
+
s.release
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
t.each(&:join)
|
93
|
+
puts
|
94
|
+
|
95
|
+
exit
|
96
|
+
binding.pry
|
97
|
+
binding.pry
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quack_concurrency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Fors
|
@@ -10,19 +10,23 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Offers concurrency tools that
|
13
|
+
description: Offers concurrency tools that could also be found in the Concurrent Ruby
|
14
|
+
project. However, all these tools will also accept duck types to allow core classes
|
14
15
|
to behave as desired.
|
15
16
|
email: mail@robfors.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
20
23
|
- lib/quack_concurrency.rb
|
21
24
|
- lib/quack_concurrency/condition_variable.rb
|
22
25
|
- lib/quack_concurrency/future.rb
|
23
26
|
- lib/quack_concurrency/reentrant_mutex.rb
|
24
27
|
- lib/quack_concurrency/semaphore.rb
|
25
28
|
- lib/quack_concurrency/waiter.rb
|
29
|
+
- test/test.rb
|
26
30
|
homepage: https://github.com/robfors/quack_concurrency
|
27
31
|
licenses:
|
28
32
|
- MIT
|
@@ -46,5 +50,5 @@ rubyforge_project:
|
|
46
50
|
rubygems_version: 2.4.8
|
47
51
|
signing_key:
|
48
52
|
specification_version: 4
|
49
|
-
summary: Concurrency tools that accept duck types.
|
53
|
+
summary: Concurrency tools that accept duck types of core classes.
|
50
54
|
test_files: []
|