fibre 0.9.10 → 0.9.11

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: 633dd9a0b26627425b640e012e692379c06f561b
4
- data.tar.gz: 5ab441c8bf6430561201b853188922658fd15cb1
3
+ metadata.gz: 6e65be0e8a0426467f29ea32e1066618aa3afc53
4
+ data.tar.gz: f25087d69f16860813085b08d67dc89c2a59e8e0
5
5
  SHA512:
6
- metadata.gz: eabdca5d1648fb3d31c20497b02616cf63fefdf5c6dcb834935d1579355d01808550f6bbbd80d132f05b9dbef6da72d07559d29e8b839c4e549c5a39498e07cb
7
- data.tar.gz: d3ede9823aa33c585841021b2e85c517bd5f7b9c24aa2ba10c8dba72097b4986a3e0d2bbbbf3eef9120e8a9049fd0b913d5830c7907587f910d01ef005752262
6
+ metadata.gz: 8d688ac79fa241e28c189acc1801024be53acd5f382de1a06b6ff21f9f288b81e5d639fc286a4e3b3a42fa7de08b8562cb17a6fb0e33af8af0e991b78b7ee899
7
+ data.tar.gz: a0e28623b90b75445a14840160f58cb9a8a91dbf47fd45a10faba53308346fbfebda688e76ae34d7f98c87adec7f5b5ee1e0b1abf56c494016f42832a4b9764d
@@ -46,7 +46,7 @@ class Fiber
46
46
  end
47
47
  end
48
48
 
49
- def leave(exception, message=nil) # deprecated
50
- raise exception.new(message)
49
+ def leave(exception, message=nil)
50
+ resume exception.is_a?(Class) ? exception.new(message) : exception
51
51
  end
52
52
  end
@@ -12,7 +12,7 @@ module Fibre
12
12
  using EventObject
13
13
 
14
14
  class FiberPool
15
- events :before, :after
15
+ events :error, :before, :after
16
16
 
17
17
  # Initialize fibers pool
18
18
  def initialize(size)
@@ -33,8 +33,7 @@ module Fibre
33
33
 
34
34
  @pool.shift.tap do |fiber|
35
35
  @reserved[fiber.object_id] = spec
36
- err = fiber.resume(spec)
37
- raise Fibre::FiberError.new(err) if err.is_a?(Exception)
36
+ fiber.resume(spec)
38
37
  end
39
38
 
40
39
  self
@@ -60,7 +59,6 @@ module Fibre
60
59
  loop do
61
60
  raise "wrong spec in fiber block" unless spec.is_a?(Hash)
62
61
 
63
- result = nil
64
62
  begin
65
63
  before!(spec)
66
64
  spec[:block].call# *Fiber.current.args
@@ -70,7 +68,11 @@ module Fibre
70
68
  # RangeError, FloatDomainError, RegexpError, RuntimeError, SecurityError, SystemCallError
71
69
  # SystemStackError, ThreadError, TypeError, ZeroDivisionError
72
70
  rescue StandardError => e
73
- result = e
71
+ if error.empty?
72
+ raise Fibre::FiberError.new(e)
73
+ else
74
+ error!(e)
75
+ end
74
76
  # catch NoMemoryError, ScriptError, SignalException, SystemExit, fatal etc
75
77
  #rescue Exception
76
78
  end
@@ -80,7 +82,7 @@ module Fibre
80
82
  next
81
83
  end
82
84
 
83
- spec = checkin(result)
85
+ spec = checkin
84
86
  end
85
87
  end
86
88
 
@@ -88,7 +90,7 @@ module Fibre
88
90
  def checkin(result=nil)
89
91
  @reserved.delete ::Fiber.current.object_id
90
92
  @pool.unshift ::Fiber.current
91
- ::Fiber.yield result
93
+ ::Fiber.yield
92
94
  end
93
95
  end
94
96
  end
@@ -1,3 +1,3 @@
1
1
  module Fibre
2
- VERSION = "0.9.10"
2
+ VERSION = "0.9.11"
3
3
  end
@@ -21,7 +21,7 @@ describe Fibre do
21
21
  expect(probe).to receive(:call)
22
22
  Fibre.pool.checkout(&probe)
23
23
  end
24
- =begin
24
+
25
25
  it "should rescue error in fiber" do
26
26
  expect(probe).to receive(:call)
27
27
  Fibre.pool.on(:error) do |error|
@@ -32,7 +32,7 @@ describe Fibre do
32
32
  raise
33
33
  end
34
34
  end
35
- =end
35
+
36
36
 
37
37
  it "should scope" do
38
38
  expect(probe).to receive(:call)
@@ -54,7 +54,7 @@ describe Fibre do
54
54
  end
55
55
  }.to raise_error
56
56
  end
57
- =begin
57
+
58
58
  it "should catch exception" do
59
59
  Fibre.pool.on :error do |error|
60
60
  # catch exception here
@@ -66,7 +66,7 @@ describe Fibre do
66
66
  end
67
67
  }.to_not raise_error
68
68
  end
69
- =end
69
+
70
70
  describe "in fiber specs" do
71
71
 
72
72
  around do |examples|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - inre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine-le