fiber-scheduler 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fiber_scheduler/compatibility.rb +10 -10
- data/lib/fiber_scheduler/version.rb +1 -1
- data/lib/fiber_scheduler.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900e46580ebb4fd13f4806ca78d4973d6a3a7794e3ab4b9587d86b271aa704c0
|
4
|
+
data.tar.gz: ac545db55582476b58171ad33e43fa8049c11aa8ced996612797162b2ef44140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28ff450320b55a2eb76a8cde225d787b7c524c2e42abad441d135764557450688606bdf03a7bea97d993b1a34e0d1fcb6e46662a5984bd26efa938f43596ed6
|
7
|
+
data.tar.gz: 33198428d0485ef90e9fd5d5017df63e7fb30957699d1c1cac06281baa88b4440a1568966b1e8dd82aa0a5736785989996c9ff4d97a084423d788dcbd1953102
|
@@ -35,8 +35,8 @@ class FiberScheduler
|
|
35
35
|
|
36
36
|
fiber
|
37
37
|
|
38
|
-
when :
|
39
|
-
# Transfer to current fiber some time after a
|
38
|
+
when :volatile
|
39
|
+
# Transfer to current fiber some time after a volatile fiber yields.
|
40
40
|
unblock(nil, Fiber.current)
|
41
41
|
# Alternative to #unblock: Fiber.scheduler.push(Fiber.current)
|
42
42
|
|
@@ -46,9 +46,9 @@ class FiberScheduler
|
|
46
46
|
rescue Close
|
47
47
|
# Fiber scheduler is closing.
|
48
48
|
ensure
|
49
|
-
|
49
|
+
_volatile.delete(Fiber.current)
|
50
50
|
end
|
51
|
-
|
51
|
+
_volatile[fiber] = nil
|
52
52
|
fiber.tap(&:transfer)
|
53
53
|
|
54
54
|
when nil
|
@@ -63,17 +63,17 @@ class FiberScheduler
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
# #close and #
|
66
|
+
# #close and #_volatile handle a complexity in Async::Scheduler#close, more
|
67
67
|
# specifically this line:
|
68
68
|
# https://github.com/socketry/async/blob/456df488d801572821eaf5ec2fda10e3b9744a5f/lib/async/scheduler.rb#L55
|
69
69
|
def close
|
70
70
|
super
|
71
71
|
rescue
|
72
|
-
if
|
72
|
+
if _volatile.empty?
|
73
73
|
Kernel.raise
|
74
74
|
else
|
75
|
-
# #dup is used because #
|
76
|
-
|
75
|
+
# #dup is used because #_volatile is modified during iteration.
|
76
|
+
_volatile.dup.each do |fiber, _|
|
77
77
|
fiber.raise(Close)
|
78
78
|
end
|
79
79
|
|
@@ -81,8 +81,8 @@ class FiberScheduler
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def
|
85
|
-
@
|
84
|
+
def _volatile
|
85
|
+
@_volatile ||= {}
|
86
86
|
end
|
87
87
|
|
88
88
|
def self.set_internal!
|
data/lib/fiber_scheduler.rb
CHANGED
@@ -68,7 +68,7 @@ module Kernel
|
|
68
68
|
|
69
69
|
fiber
|
70
70
|
|
71
|
-
when :
|
71
|
+
when :volatile
|
72
72
|
scheduler.unblock(nil, Fiber.current)
|
73
73
|
|
74
74
|
fiber = Fiber.new(blocking: false) do
|
@@ -77,9 +77,9 @@ module Kernel
|
|
77
77
|
rescue FiberScheduler::Compatibility::Close
|
78
78
|
# Fiber scheduler is closing.
|
79
79
|
ensure
|
80
|
-
scheduler.
|
80
|
+
scheduler._volatile.delete(Fiber.current)
|
81
81
|
end
|
82
|
-
scheduler.
|
82
|
+
scheduler._volatile[fiber] = nil
|
83
83
|
fiber.tap(&:transfer)
|
84
84
|
|
85
85
|
when nil
|
@@ -221,7 +221,7 @@ class FiberScheduler
|
|
221
221
|
|
222
222
|
fiber
|
223
223
|
|
224
|
-
when :
|
224
|
+
when :volatile
|
225
225
|
if current != @fiber
|
226
226
|
# nested Fiber.schedule
|
227
227
|
@nested << current
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiber-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Sutic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|