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 +4 -4
- data/lib/fibre/core_ext/fiber.rb +2 -2
- data/lib/fibre/fiber_pool.rb +9 -7
- data/lib/fibre/version.rb +1 -1
- data/spec/fibre_spec.rb +4 -4
- 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: 6e65be0e8a0426467f29ea32e1066618aa3afc53
|
4
|
+
data.tar.gz: f25087d69f16860813085b08d67dc89c2a59e8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d688ac79fa241e28c189acc1801024be53acd5f382de1a06b6ff21f9f288b81e5d639fc286a4e3b3a42fa7de08b8562cb17a6fb0e33af8af0e991b78b7ee899
|
7
|
+
data.tar.gz: a0e28623b90b75445a14840160f58cb9a8a91dbf47fd45a10faba53308346fbfebda688e76ae34d7f98c87adec7f5b5ee1e0b1abf56c494016f42832a4b9764d
|
data/lib/fibre/core_ext/fiber.rb
CHANGED
data/lib/fibre/fiber_pool.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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
|
93
|
+
::Fiber.yield
|
92
94
|
end
|
93
95
|
end
|
94
96
|
end
|
data/lib/fibre/version.rb
CHANGED
data/spec/fibre_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe Fibre do
|
|
21
21
|
expect(probe).to receive(:call)
|
22
22
|
Fibre.pool.checkout(&probe)
|
23
23
|
end
|
24
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine-le
|