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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ebb8de7090ed5a5d23691d8571baeb429b48a9f074732c236224e070beb494c
4
- data.tar.gz: 3146ab6d57971fd5ac44649c866e9cdaade193d42281e1cdd6c2bfc4b95b134a
3
+ metadata.gz: c52199c3ce4eba08ef132232f2d812f38697dee26f4e58afd864dc35ecbe55d3
4
+ data.tar.gz: f1de4b8cf0d1343d5acbaa0d83219e4abd8a4c1b7a23730d1e235c4d7558b98f
5
5
  SHA512:
6
- metadata.gz: 325838cec3b84c9d3f90f4d79dd7fb927275edbd547f9205bac7e31c8dd0e02aaf7c7030d82223f2c05a6b3ee2ef1e889b824640f8e81f8c9f307b40d751e12b
7
- data.tar.gz: 7ffee495a8907695266b22696a8ecece4a2beb73b5ba392ad37332b1671bbb6ab6d063aec96ce4410524c2afef8dec0f66ea141a8bdcbcd64ee4cb24340fffe3
6
+ metadata.gz: 7faeea996aeaa8ef7ccecaca1d3c547dec8dc9bde59a7eb7ca27b4186378d6f7646ea5f78bba6b974464116f43ecacce1c80522467b7cff7a32c25d82bd5ee26
7
+ data.tar.gz: dd53e5af1f0b70a80354074de3d9554f8e6320b9362637fd8c6c8c15affcb3a1ac0c06a14ff4c04842fd9daae42b5bb1dd27cad1ecfb4e08cab1dc1c931975fc
@@ -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 stop
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
- @threads.each(&:join)
60
+
61
+ wait
49
62
  end
50
63
  end
51
64
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Container
23
- VERSION = "0.3.0"
23
+ VERSION = "0.4.0"
24
24
  end
25
25
  end
@@ -21,6 +21,8 @@
21
21
  require "async/container"
22
22
 
23
23
  RSpec.describe Async::Container do
24
+ include_context Async::RSpec::Reactor
25
+
24
26
  it "can run concurrently" do
25
27
  count = 0
26
28
 
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.3.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