async 0.15.0 → 0.16.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
  SHA1:
3
- metadata.gz: 58e790ceb3a44709f35f90e0cb35c15a9a251ada
4
- data.tar.gz: 052dfc0e8afd64422e0a1703134b333c9271b8f6
3
+ metadata.gz: b09ff3d20b66fd1a908bbf44ba04e10fb6b633cf
4
+ data.tar.gz: 287bc69ce12fb51c1b1412749ed3fe62473a6673
5
5
  SHA512:
6
- metadata.gz: 02e888c50e3dd0e20798fc53b2b5f83f7c4d66e6b4686cac13e0efd5704fffc13836933df20d72e8731a4db168a7c0f42266e18dee4bc76f54b52f3d47173ed1
7
- data.tar.gz: 59050ea66f4f9a780b1e78c1d646cb8a178f43535d10ed5d75d38b9020da3c3984779c6016a7b962a35b24443e11081d64da891606a8251a1be6acb43138f746
6
+ metadata.gz: e3eee05641978320874385017b666d4e7daf02ebc2bfa22ce8eeab6ece962322a645b1e8d6896dc744ef1a428ba48f6f633ad27335dc7573c570ba97ee89bdbb
7
+ data.tar.gz: 50f17f1f2213b2afeeb5c0bfe63ed6aae31e98b81d45f9f6bacb1f752808278456ed9e7f19d928d9c7ab459f8ec3f78e638c5bf97a222dee078e6b3fddc0a196
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Async
22
- VERSION = "0.15.0"
22
+ VERSION = "0.16.0"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -115,7 +115,6 @@ files:
115
115
  - async.gemspec
116
116
  - lib/async.rb
117
117
  - lib/async/condition.rb
118
- - lib/async/container.rb
119
118
  - lib/async/logger.rb
120
119
  - lib/async/node.rb
121
120
  - lib/async/reactor.rb
@@ -123,7 +122,6 @@ files:
123
122
  - lib/async/version.rb
124
123
  - lib/async/wrapper.rb
125
124
  - spec/async/condition_spec.rb
126
- - spec/async/container_spec.rb
127
125
  - spec/async/node_spec.rb
128
126
  - spec/async/reactor/nested_spec.rb
129
127
  - spec/async/reactor_spec.rb
@@ -156,7 +154,6 @@ specification_version: 4
156
154
  summary: Async is an asynchronous I/O framework based on nio4r.
157
155
  test_files:
158
156
  - spec/async/condition_spec.rb
159
- - spec/async/container_spec.rb
160
157
  - spec/async/node_spec.rb
161
158
  - spec/async/reactor/nested_spec.rb
162
159
  - spec/async/reactor_spec.rb
@@ -1,70 +0,0 @@
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_relative 'reactor'
22
- require 'thread'
23
-
24
- module Async
25
- # 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.
26
- # Manages a reactor within one or more threads.
27
- module Container
28
- def self.new(klass: ThreadContainer, **options, &block)
29
- klass.new(**options, &block)
30
- end
31
- end
32
-
33
- class ThreadContainer
34
- def initialize(concurrency: 1, &block)
35
- @reactors = concurrency.times.collect do
36
- Async::Reactor.new
37
- end
38
-
39
- @threads = @reactors.collect do |reactor|
40
- Thread.new do
41
- Thread.current.abort_on_exception = true
42
-
43
- reactor.run(&block)
44
- end
45
- end
46
- end
47
-
48
- def stop
49
- @reactors.each(&:stop)
50
- @threads.each(&:join)
51
- end
52
- end
53
-
54
- class ProcessContainer
55
- def initialize(concurrency: 1, &block)
56
- @pids = concurrency.times.collect do
57
- fork do
58
- Async::Reactor.run(&block)
59
- end
60
- end
61
- end
62
-
63
- def stop
64
- @pids.each do |pid|
65
- Process.kill(:INT, pid) rescue nil
66
- Process.wait(pid)
67
- end
68
- end
69
- end
70
- end
@@ -1,35 +0,0 @@
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"
22
-
23
- RSpec.describe Async::Container do
24
- it "can run concurrently" do
25
- count = 0
26
-
27
- container = described_class.new do
28
- count += 1
29
- end
30
-
31
- container.stop
32
-
33
- expect(count).to be == 1
34
- end
35
- end