legion 0.0.7 → 0.1.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 +4 -4
- data/bin/legion_demo +5 -1
- data/lib/legion/object.rb +5 -5
- data/lib/legion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006f2c90438dfe8c72bd8d75baab387236054d79
|
4
|
+
data.tar.gz: ba2d996de7fb9386114818d1dd9779e25526bd79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3978c05cbf8fc99c6126336d8d540c45a1c51c75ee871985f03f6955366e2947005921a9abdc17e04df454d09b7f1ba9435c8fc8eee8074261f89a76fb148e3
|
7
|
+
data.tar.gz: e6691c66995540326c284c7adaeeabfbe09ba8d5a7e26a57189405c8be5aec4420df59073a5277cfa0506502b7809cb4b74b550ca6f66f08ffe954099d8f6c5a
|
data/bin/legion_demo
CHANGED
@@ -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
|
-
|
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"
|
data/lib/legion/object.rb
CHANGED
@@ -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
|
23
|
-
@
|
21
|
+
def after_fork(&block)
|
22
|
+
@after_fork = block
|
24
23
|
end
|
25
24
|
|
26
|
-
def
|
27
|
-
|
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
|
data/lib/legion/version.rb
CHANGED
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
|
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
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|