zmachine 0.4.2 → 0.4.3

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: 678962082b59e5cd14cafa1854e9824d7b92635d
4
- data.tar.gz: 89c609b6ea82d80371806d62974ae25baab8ad59
3
+ metadata.gz: 2d4e45964f4ad8cc75670cc74dbac343334027e8
4
+ data.tar.gz: e3a54b002782ea788369586b73079d05fe0b2655
5
5
  SHA512:
6
- metadata.gz: 06a8730505de6a152fe7d3302b416cb040a3df5c2daa11c75ee0a3b4f4740ec44f3b013438666b63e0b3997e6b5a61fbd3ce1be5c24abac8f8917df38ac68a5d
7
- data.tar.gz: 080046c1498d52f1052200dbfb5dcf0b80a12f357728bb9bd55fffac4bbdb2b38b2899912061658ba56d07b6917b4f393408b3c8c6997acc8619b53bc6375121
6
+ metadata.gz: 3dd61a9c2fbe3985a37f1f655bba28f517fc624b2e1808b7e197430dd7a9b336d3363ba2bcbf899f7d1391ee052308e7af1d50d3809feaf6d1d05fb83e4f3e8e
7
+ data.tar.gz: 79dd248e44b43da0a0deeb3bc6fa95598302088aba606893356ed517dbcca8b17f5aec8d1dc5846530551126a3c0406d665954f7a446957b8fb53b35bb8e2ac5
@@ -100,6 +100,10 @@ module ZMachine
100
100
  reactor.stop_server(signature)
101
101
  end
102
102
 
103
+ def self.stop
104
+ Reactor.terminate_all_reactors
105
+ end
106
+
103
107
  end
104
108
 
105
109
  if ENV['DEBUG']
@@ -12,6 +12,28 @@ module ZMachine
12
12
 
13
13
  class Reactor
14
14
 
15
+ @mutex = Mutex.new
16
+
17
+ def self.register_reactor(reactor)
18
+ @mutex.synchronize do
19
+ @reactors ||= []
20
+ @reactors << reactor
21
+ end
22
+ end
23
+
24
+ def self.terminate_all_reactors
25
+ @mutex.synchronize do
26
+ @reactors.each(&:stop_event_loop)
27
+ @reactors.clear
28
+ end
29
+ end
30
+
31
+ def self.unregister_reactor(reactor)
32
+ @mutex.synchronize do
33
+ @reactors.delete(reactor)
34
+ end
35
+ end
36
+
15
37
  def initialize
16
38
  @heartbeat_interval = ZMachine.heartbeat_interval || 0.5 # coarse grained by default
17
39
  @next_tick_queue = ConcurrentLinkedQueue.new
@@ -79,7 +101,7 @@ module ZMachine
79
101
  ZMachine.logger.debug("zmachine:reactor:#{__method__}") if ZMachine.debug
80
102
  add_shutdown_hook(shutdown_hook) if shutdown_hook
81
103
  begin
82
- Signal.register_shutdown_handler { self.stop_event_loop }
104
+ Reactor.register_reactor(self)
83
105
  @running = true
84
106
  if callback = (callback || block)
85
107
  add_timer(0) { callback.call(self) }
@@ -98,6 +120,7 @@ module ZMachine
98
120
  @shutdown_hooks.pop.call until @shutdown_hooks.empty?
99
121
  @next_tick_queue = ConcurrentLinkedQueue.new
100
122
  @running = false
123
+ Reactor.unregister_reactor(self)
101
124
  ZMachine.logger.debug("zmachine:reactor:#{__method__}", stop: :zcontext) if ZMachine.debug
102
125
  ZMachine.reactor = nil
103
126
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "zmachine"
5
- spec.version = "0.4.2"
5
+ spec.version = "0.4.3"
6
6
  spec.authors = ["LiquidM, Inc."]
7
7
  spec.email = ["opensource@liquidm.com"]
8
8
  spec.description = %q{pure JRuby multi-threaded mostly EventMachine compatible event loop}
@@ -15,5 +15,5 @@ Gem::Specification.new do |spec|
15
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
16
  spec.require_paths = ["lib"]
17
17
 
18
- spec.add_dependency "liquid-ext", ">= 3.3.8"
18
+ spec.add_dependency "liquid-ext", ">= 3.3.9"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - LiquidM, Inc.
@@ -16,12 +16,12 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.8
19
+ version: 3.3.9
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
22
  - - '>='
23
23
  - !ruby/object:Gem::Version
24
- version: 3.3.8
24
+ version: 3.3.9
25
25
  prerelease: false
26
26
  type: :runtime
27
27
  description: pure JRuby multi-threaded mostly EventMachine compatible event loop