parallizer 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parallizer (0.4.3)
4
+ parallizer (0.4.5)
5
5
  celluloid (~> 0.11.0)
6
- hanging_methods (~> 0.0.1)
6
+ hanging_methods (~> 0.0.2)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
data/lib/parallizer.rb CHANGED
@@ -30,6 +30,10 @@ class Parallizer
30
30
 
31
31
  queue
32
32
  end
33
+
34
+ def in_parallizer_thread?
35
+ Thread.current[:parallizer_thread] == true
36
+ end
33
37
  end
34
38
 
35
39
  attr_reader :calls, :call_infos, :client, :proxy, :options
@@ -1,3 +1,3 @@
1
1
  class Parallizer
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -7,14 +7,18 @@ class Parallizer
7
7
 
8
8
  (options[:retries] + 1).times do
9
9
  begin
10
+ Thread.current[:parallizer_thread] = true
11
+
10
12
  result[:exception] = nil # reset exception before each send attempt
11
13
  result[:result] = client.send(method_name, *args)
12
14
  break # success
13
15
  rescue Exception => e
14
16
  result[:exception] = e
17
+ ensure
18
+ Thread.current[:parallizer_thread] = nil
15
19
  end
16
20
  end
17
-
21
+
18
22
  result
19
23
  end
20
24
  end
@@ -18,6 +18,10 @@ describe Parallizer do
18
18
  def another_current_thread
19
19
  Thread.current
20
20
  end
21
+
22
+ def in_parallizer_thread?
23
+ Parallizer.in_parallizer_thread?
24
+ end
21
25
  end
22
26
 
23
27
  class AnotherTestObject
@@ -30,6 +34,28 @@ describe Parallizer do
30
34
  end
31
35
  end
32
36
 
37
+ describe "#in_parallizer_thread?" do
38
+ before do
39
+ @client = TestObject.new
40
+ @parallizer = Parallizer.new(@client)
41
+ end
42
+
43
+ subject do
44
+ parallizer = Parallizer.new(@client)
45
+ parallizer.add.in_parallizer_thread?
46
+ proxy = parallizer.create_proxy
47
+ proxy.in_parallizer_thread?
48
+ end
49
+
50
+ it "is not in_parallizer_thread on the client" do
51
+ @client.in_parallizer_thread?.should be_false
52
+ end
53
+
54
+ it "is in_parallizer_thread after parallizing" do
55
+ subject.should be_true
56
+ end
57
+ end
58
+
33
59
  describe "#add" do
34
60
  before do
35
61
  @client = TestObject.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-31 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid