worker 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/examples/args.rb +18 -0
- data/lib/worker.rb +2 -1
- data/worker.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 230e471bd7fe37454a7ba582b15e4f06ef17bdc037b021d903a60e3f3307e0c9
|
4
|
+
data.tar.gz: 3ac9095f860d85be292ca7a7b9533ad4153ddbfcb7ac736b58852cc9cb0ec85a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a5843f71ff52a7754ae8b3735d5b01797523057a6076a71ceea8c092edfa4d6b8e1c4ab6a71282c7c4629b7d5a0c372b9ed472cef6cab51780676503725ac4
|
7
|
+
data.tar.gz: e01fbdbb7419d413a303a42ec4cf78e7641f7b1bf4578f13d32e868ec40b8364663e849587f2c708bf2429b4c4658380f76ab9f749f53bff05c457ddc672444f
|
data/Gemfile.lock
CHANGED
data/examples/args.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "../lib/worker"
|
2
|
+
|
3
|
+
binary = Worker.new do |a,b|
|
4
|
+
raise "binary: a not integer" unless a.is_a? Integer
|
5
|
+
raise "binary: b not integer" unless b.is_a? Integer
|
6
|
+
end
|
7
|
+
|
8
|
+
unary = Worker.new do |a|
|
9
|
+
raise "unary: a not integer" unless a.is_a? Integer
|
10
|
+
end
|
11
|
+
|
12
|
+
unary_array = Worker.new do |a|
|
13
|
+
raise "unary_array: a not array" unless a.is_a? Array
|
14
|
+
end
|
15
|
+
|
16
|
+
binary.perform 1, 2
|
17
|
+
unary.perform 1
|
18
|
+
unary_array.perform [1]
|
data/lib/worker.rb
CHANGED
@@ -13,6 +13,7 @@ class Worker
|
|
13
13
|
|
14
14
|
def perform(*args)
|
15
15
|
@in.push args
|
16
|
+
|
16
17
|
ret = @out.pop
|
17
18
|
if ret.is_a? Exception
|
18
19
|
raise ret
|
@@ -24,7 +25,7 @@ class Worker
|
|
24
25
|
def run!
|
25
26
|
@thread = Thread.new do
|
26
27
|
loop do
|
27
|
-
ret = @ctx.instance_exec
|
28
|
+
ret = @ctx.instance_exec *@in.pop, &@block
|
28
29
|
@out.push ret
|
29
30
|
rescue Exception => ex
|
30
31
|
@out.push ex
|
data/worker.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/setup
|
74
74
|
- examples/adder_memo.rb
|
75
|
+
- examples/args.rb
|
75
76
|
- examples/simple.rb
|
76
77
|
- lib/worker.rb
|
77
78
|
- worker.gemspec
|