async-container 0.7.0 → 0.8.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: 1c818065938381f0420016a5b125b2239e573c4579b8d30610868e8bc3982c17
4
- data.tar.gz: c1885a7f1ca4fef393f5f0488503ae13021524d75644d364280ed93aace53c3a
3
+ metadata.gz: 45319be8ef742bece1def74c0ac58a0bb3450f3bec0c80dc34eca3bf28f284eb
4
+ data.tar.gz: 400b19815897816a89b529a45c95a036a95feb5eed59cc615d88542933d6d974
5
5
  SHA512:
6
- metadata.gz: e4171cae3e19524640ea3a0a56487e4e8c7bae341f0f89c166e3cc3a4c1f71875da8491af3f01c73093add6dbfddfc7b2a52749d339f9fd838e6c073180c4cc9
7
- data.tar.gz: 655afe1621ae3a4b6d2ebca90de90e6c15a2e0d993395c38c1b6391bcf66fdee2b067fcc972b71228180ea612908156fd2dbf8ad2f9d4a50cd3840b4ed83b291
6
+ metadata.gz: 91fe53a2d4276196a4dedeb0b66a09c35acb55c06a2f1c7ab5c2708536b40f79914a78d02f1919ca6125cfe68a6b4c1ec967493452262f736f57c751c63b23eb
7
+ data.tar.gz: 027e9c42c8baa011019ffb42e82646194fff2d54c3a902323aae2d64646f35a224052c309ce5a118c2b4255052616165422c90b42c56f65b0381a73493bb8a19
@@ -26,13 +26,22 @@ module Async
26
26
  # Manages a reactor within one or more threads.
27
27
  module Container
28
28
  class Forked
29
+ class Instance
30
+ def initialize
31
+ end
32
+
33
+ def name= value
34
+ Process.setproctitle(value)
35
+ end
36
+ end
37
+
29
38
  def initialize(concurrency: 1, name: nil, &block)
30
39
  @pids = concurrency.times.collect do
31
40
  fork do
32
41
  Process.setproctitle(name) if name
33
42
 
34
43
  begin
35
- Async::Reactor.run(&block)
44
+ Async::Reactor.run(Instance.new, &block)
36
45
  rescue Interrupt
37
46
  # Exit cleanly.
38
47
  end
@@ -27,6 +27,16 @@ module Async
27
27
  module Container
28
28
  # Manages a reactor within one or more threads.
29
29
  class Threaded
30
+ class Instance
31
+ def initialize(thread)
32
+ @thread = thread
33
+ end
34
+
35
+ def name= value
36
+ @thread.name = value
37
+ end
38
+ end
39
+
30
40
  def initialize(concurrency: 1, name: nil, &block)
31
41
  @reactors = concurrency.times.collect do
32
42
  Async::Reactor.new
@@ -40,7 +50,7 @@ module Async
40
50
  thread.name = name if name
41
51
 
42
52
  begin
43
- reactor.run(&block)
53
+ reactor.run(Instance.new(thread), &block)
44
54
  rescue Interrupt
45
55
  # Exit cleanly.
46
56
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Container
23
- VERSION = "0.7.0"
23
+ VERSION = "0.8.0"
24
24
  end
25
25
  end
@@ -22,7 +22,9 @@ require "async/container/forked"
22
22
 
23
23
  RSpec.describe Async::Container::Forked do
24
24
  it "can run concurrently" do
25
- container = described_class.new(concurrency: 8, name: "Sleepy Jerry") do
25
+ container = described_class.new(concurrency: 8, name: "Sleepy Jerry") do |task, instance|
26
+ instance.name = "Hello World"
27
+
26
28
  sleep 1
27
29
  end
28
30
 
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams