async-container 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/container/controller.rb +43 -0
- data/lib/async/container/version.rb +1 -1
- data/spec/async/container/controller_spec.rb +43 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73a263e2c02d34493e16670460a147f73f12ef2921479e94d11ba9e44b53a148
|
4
|
+
data.tar.gz: d2d05efd1072122a4955d9fa9f3f37785ae8ea25a34ca5b7948665370075f79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff85374f4f81d5ed972024a6c34abb47c07795cfbd7da1155c56e691335e1635fcb525fe61a016c85443af8470a9aa728ab93d315fd08fc79218686ce89e32e9
|
7
|
+
data.tar.gz: 000aa3df432c304949d7e5df6e777748bba89db63351181b7b2e73bd0a5953c8a204edc81b255d5635da892d1605ba7db75dc4f80b8651ac344515a0441271d5
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'async/reactor'
|
22
|
+
|
23
|
+
module Async
|
24
|
+
module Container
|
25
|
+
class Controller
|
26
|
+
def initialize
|
27
|
+
@containers = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def << container
|
31
|
+
@containers << container
|
32
|
+
end
|
33
|
+
|
34
|
+
def wait
|
35
|
+
@containers.each(&:wait)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stop
|
39
|
+
@containers.each(&:stop)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require "async/container/controller"
|
22
|
+
|
23
|
+
RSpec.describe Async::Container::Controller do
|
24
|
+
it 'can manage multiple containers' do
|
25
|
+
mutex = Mutex.new
|
26
|
+
count = 0
|
27
|
+
|
28
|
+
subject << Async::Container::Threaded.new(concurrency: 2) do
|
29
|
+
mutex.synchronize do
|
30
|
+
count += 1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
subject << Async::Container::Threaded.new(concurrency: 2) do
|
35
|
+
mutex.synchronize do
|
36
|
+
count += 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
subject.wait
|
41
|
+
expect(count).to be == 4
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -113,9 +113,11 @@ files:
|
|
113
113
|
- Rakefile
|
114
114
|
- async-container.gemspec
|
115
115
|
- lib/async/container.rb
|
116
|
+
- lib/async/container/controller.rb
|
116
117
|
- lib/async/container/forked.rb
|
117
118
|
- lib/async/container/threaded.rb
|
118
119
|
- lib/async/container/version.rb
|
120
|
+
- spec/async/container/controller_spec.rb
|
119
121
|
- spec/async/container_spec.rb
|
120
122
|
- spec/spec_helper.rb
|
121
123
|
homepage: https://github.com/socketry/async-container
|
@@ -143,5 +145,6 @@ signing_key:
|
|
143
145
|
specification_version: 4
|
144
146
|
summary: Async is an asynchronous I/O framework based on nio4r.
|
145
147
|
test_files:
|
148
|
+
- spec/async/container/controller_spec.rb
|
146
149
|
- spec/async/container_spec.rb
|
147
150
|
- spec/spec_helper.rb
|