legion 0.0.7 → 0.1.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: fd69818926d0f41b603632afaf91c6b257fd9151
4
- data.tar.gz: 7eca50ed8192c289c2b9414ee9996e2b12f2a36b
3
+ metadata.gz: 006f2c90438dfe8c72bd8d75baab387236054d79
4
+ data.tar.gz: ba2d996de7fb9386114818d1dd9779e25526bd79
5
5
  SHA512:
6
- metadata.gz: cc8a23b37cbec7e348281a8f70537d90c5acb2eeaafb8650a161dc720e11c82c8bd88de935cc2b0522d56aeceeafed29c65f826cb9bee65dcf5ae41d718529c6
7
- data.tar.gz: 425a8a393945f8d9fefb22abab9082dcc346efc643c85e6ac9b9e7a80273e0ab103121ea69f688994fb5a20a39b5571a8325464f7d1e40b0ed95fc70196e7b57
6
+ metadata.gz: f3978c05cbf8fc99c6126336d8d540c45a1c51c75ee871985f03f6955366e2947005921a9abdc17e04df454d09b7f1ba9435c8fc8eee8074261f89a76fb148e3
7
+ data.tar.gz: e6691c66995540326c284c7adaeeabfbe09ba8d5a7e26a57189405c8be5aec4420df59073a5277cfa0506502b7809cb4b74b550ca6f66f08ffe954099d8f6c5a
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env ruby --
2
2
 
3
3
  require "legion"
4
+ #require_relative "../lib/legion"
4
5
 
5
6
  class Example < Legion::Object
6
- before(:work) { puts "before hook invoked" }
7
+
8
+ after_fork do
9
+ puts "object is running in a new process"
10
+ end
7
11
 
8
12
  def work(index)
9
13
  puts "working on: #{index} ... sleeping for 2 seconds"
@@ -12,19 +12,18 @@ module Legion
12
12
  define_method "#{name}_async" do |*args|
13
13
  Thread.new do
14
14
  synchronize { @busy = true }
15
- self.class.callbacks[:before][name].call unless self.class.callbacks[:before][name].nil?
16
15
  send(name, *args)
17
16
  synchronize { @busy = false }
18
17
  end
19
18
  end
20
19
  end
21
20
 
22
- def callbacks
23
- @callbacks ||= {before: {}}
21
+ def after_fork(&block)
22
+ @after_fork = block
24
23
  end
25
24
 
26
- def before(name, &block)
27
- callbacks[:before][name] = block
25
+ def fork_callback
26
+ @after_fork ||= lambda {}
28
27
  end
29
28
  end
30
29
 
@@ -43,6 +42,7 @@ module Legion
43
42
  @uri = "druby://localhost:#{port}"
44
43
  @pid = fork do
45
44
  DRb.start_service uri, self
45
+ self.class.fork_callback.call
46
46
  DRb.thread.join
47
47
  end
48
48
  Process.detach pid
@@ -1,3 +1,3 @@
1
1
  module Legion
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler