async-container 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 +4 -4
- data/async-container.gemspec +2 -0
- data/lib/async/container/forked.rb +17 -3
- data/lib/async/container/threaded.rb +14 -1
- data/lib/async/container/version.rb +1 -1
- data/spec/async/container_spec.rb +2 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52199c3ce4eba08ef132232f2d812f38697dee26f4e58afd864dc35ecbe55d3
|
4
|
+
data.tar.gz: f1de4b8cf0d1343d5acbaa0d83219e4abd8a4c1b7a23730d1e235c4d7558b98f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7faeea996aeaa8ef7ccecaca1d3c547dec8dc9bde59a7eb7ca27b4186378d6f7646ea5f78bba6b974464116f43ecacce1c80522467b7cff7a32c25d82bd5ee26
|
7
|
+
data.tar.gz: dd53e5af1f0b70a80354074de3d9554f8e6320b9362637fd8c6c8c15affcb3a1ac0c06a14ff4c04842fd9daae42b5bb1dd27cad1ecfb4e08cab1dc1c931975fc
|
data/async-container.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.required_ruby_version = "~> 2.0"
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "async", "~> 1.0"
|
25
|
+
spec.add_runtime_dependency "async-io", "~> 1.4"
|
26
|
+
|
25
27
|
spec.add_development_dependency "async-rspec", "~> 1.1"
|
26
28
|
|
27
29
|
spec.add_development_dependency "bundler", "~> 1.3"
|
@@ -20,8 +20,9 @@
|
|
20
20
|
|
21
21
|
require 'async/reactor'
|
22
22
|
|
23
|
+
require 'async/io/notification'
|
24
|
+
|
23
25
|
module Async
|
24
|
-
# TODO Move this into it's own gem, since it's really not required for async to work - it's only really for servers and this implementation is very basic.
|
25
26
|
# Manages a reactor within one or more threads.
|
26
27
|
module Container
|
27
28
|
class Forked
|
@@ -35,13 +36,26 @@ module Async
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
39
|
+
|
40
|
+
@finished = false
|
38
41
|
end
|
39
42
|
|
40
|
-
def
|
43
|
+
def wait
|
44
|
+
return if @finished
|
45
|
+
|
41
46
|
@pids.each do |pid|
|
42
|
-
Process.kill(:INT, pid) rescue nil
|
43
47
|
Process.wait(pid)
|
44
48
|
end
|
49
|
+
|
50
|
+
@finished = true
|
51
|
+
end
|
52
|
+
|
53
|
+
def stop(signal = :INT)
|
54
|
+
@pids.each do |pid|
|
55
|
+
Process.kill(signal, pid) rescue nil
|
56
|
+
end
|
57
|
+
|
58
|
+
wait
|
45
59
|
end
|
46
60
|
end
|
47
61
|
end
|
@@ -21,6 +21,8 @@
|
|
21
21
|
require 'async/reactor'
|
22
22
|
require 'thread'
|
23
23
|
|
24
|
+
require 'async/io/notification'
|
25
|
+
|
24
26
|
module Async
|
25
27
|
module Container
|
26
28
|
# Manages a reactor within one or more threads.
|
@@ -41,11 +43,22 @@ module Async
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
46
|
+
|
47
|
+
@finished = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def wait
|
51
|
+
return if @finished
|
52
|
+
|
53
|
+
@threads.each(&:join)
|
54
|
+
|
55
|
+
@finished = true
|
44
56
|
end
|
45
57
|
|
46
58
|
def stop
|
47
59
|
@reactors.each(&:stop)
|
48
|
-
|
60
|
+
|
61
|
+
wait
|
49
62
|
end
|
50
63
|
end
|
51
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: async-io
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: async-rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|