async-container 0.6.1 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaba23f0a9e9582341135432f28ad17807045f94d2334e62156d8f3e7e1c14f9
4
- data.tar.gz: 5991162518e407fe2b4acb608cfdf85820aec1a4cc4abd9d853abe61cc27a08c
3
+ metadata.gz: 1c818065938381f0420016a5b125b2239e573c4579b8d30610868e8bc3982c17
4
+ data.tar.gz: c1885a7f1ca4fef393f5f0488503ae13021524d75644d364280ed93aace53c3a
5
5
  SHA512:
6
- metadata.gz: 3b3a38a726c95a8dfe64bba0c00432f33efc33dd2174bc3cbef9edbe3738fe8fc652e2e2fd8ce4774d1269f789075f874201d4629e9a7661c6d84d2e1c00d4e1
7
- data.tar.gz: 66f8cd6e2726f995d13fc4a16f6dcacfe69ab04b0679b95ceec0a9cf54b399407201d700c156aa802369e0d56de6603b5201352ca02a90cbe3fad513c243e3f7
6
+ metadata.gz: e4171cae3e19524640ea3a0a56487e4e8c7bae341f0f89c166e3cc3a4c1f71875da8491af3f01c73093add6dbfddfc7b2a52749d339f9fd838e6c073180c4cc9
7
+ data.tar.gz: 655afe1621ae3a4b6d2ebca90de90e6c15a2e0d993395c38c1b6391bcf66fdee2b067fcc972b71228180ea612908156fd2dbf8ad2f9d4a50cd3840b4ed83b291
@@ -1,4 +1,4 @@
1
- # -*- encoding: utf-8 -*-
1
+
2
2
  require_relative 'lib/async/container/version'
3
3
 
4
4
  Gem::Specification.new do |spec|
@@ -17,7 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
- spec.has_rdoc = "yard"
21
20
 
22
21
  spec.required_ruby_version = "~> 2.0"
23
22
 
@@ -26,9 +26,11 @@ module Async
26
26
  # Manages a reactor within one or more threads.
27
27
  module Container
28
28
  class Forked
29
- def initialize(concurrency: 1, &block)
29
+ def initialize(concurrency: 1, name: nil, &block)
30
30
  @pids = concurrency.times.collect do
31
31
  fork do
32
+ Process.setproctitle(name) if name
33
+
32
34
  begin
33
35
  Async::Reactor.run(&block)
34
36
  rescue Interrupt
@@ -27,14 +27,17 @@ module Async
27
27
  module Container
28
28
  # Manages a reactor within one or more threads.
29
29
  class Threaded
30
- def initialize(concurrency: 1, &block)
30
+ def initialize(concurrency: 1, name: nil, &block)
31
31
  @reactors = concurrency.times.collect do
32
32
  Async::Reactor.new
33
33
  end
34
34
 
35
35
  @threads = @reactors.collect do |reactor|
36
36
  Thread.new do
37
- Thread.current.abort_on_exception = true
37
+ thread = Thread.current
38
+
39
+ thread.abort_on_exception = true
40
+ thread.name = name if name
38
41
 
39
42
  begin
40
43
  reactor.run(&block)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Container
23
- VERSION = "0.6.1"
23
+ VERSION = "0.7.0"
24
24
  end
25
25
  end
@@ -0,0 +1,31 @@
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/container/forked"
22
+
23
+ RSpec.describe Async::Container::Forked do
24
+ it "can run concurrently" do
25
+ container = described_class.new(concurrency: 8, name: "Sleepy Jerry") do
26
+ sleep 1
27
+ end
28
+
29
+ container.wait
30
+ end
31
+ end
@@ -0,0 +1,31 @@
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/container/threaded"
22
+
23
+ RSpec.describe Async::Container::Threaded do
24
+ it "can run concurrently" do
25
+ container = described_class.new(concurrency: 8, name: "Sleepy Jerry") do
26
+ sleep 1
27
+ end
28
+
29
+ container.stop
30
+ end
31
+ 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.6.1
4
+ version: 0.7.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-08-18 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -118,6 +118,8 @@ files:
118
118
  - lib/async/container/threaded.rb
119
119
  - lib/async/container/version.rb
120
120
  - spec/async/container/controller_spec.rb
121
+ - spec/async/container/forked_spec.rb
122
+ - spec/async/container/threaded_spec.rb
121
123
  - spec/async/container_spec.rb
122
124
  - spec/spec_helper.rb
123
125
  homepage: https://github.com/socketry/async-container
@@ -140,11 +142,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
142
  version: '0'
141
143
  requirements: []
142
144
  rubyforge_project:
143
- rubygems_version: 2.7.6
145
+ rubygems_version: 2.7.7
144
146
  signing_key:
145
147
  specification_version: 4
146
148
  summary: Async is an asynchronous I/O framework based on nio4r.
147
149
  test_files:
148
150
  - spec/async/container/controller_spec.rb
151
+ - spec/async/container/forked_spec.rb
152
+ - spec/async/container/threaded_spec.rb
149
153
  - spec/async/container_spec.rb
150
154
  - spec/spec_helper.rb