Module: Cocaine::Synchrony
- Defined in:
- lib/cocaine/namespace.rb,
lib/cocaine/synchrony/service.rb
Defined Under Namespace
Classes: Channel, Service
Class Method Summary
collapse
Class Method Details
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/cocaine/synchrony/service.rb', line 6
def self.sync(df)
fb = Fiber.current
df.callback do |result|
if fb == Fiber.current
return result
else
fb.resume result
end
end
df.errback do |err|
if fb == Fiber.current
raise err
else
fb.resume err
end
end
result = Fiber.yield
if result.is_a? Exception
raise result
else
return result
end
end
|