celluloid 0.15.0.pre2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/celluloid.rb +4 -11
- data/lib/celluloid/actor.rb +13 -0
- data/lib/celluloid/tasks.rb +3 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e245e48da91f90663b7d0ebc235c09e31ab2c4c8
|
4
|
+
data.tar.gz: 90be7b8790c63dfa656e9ddba3e7c97118b9c27c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab5dcbccea33be7e208ec0b83195351843760f45caf65f8b5505239f1822a9042f46c5071fbfd55eba8c0c8e6f01fb35b4849a7d539e9763f542bef2153c478d
|
7
|
+
data.tar.gz: f0d86887d99804ace8cb1e14e3b0c0285f4e31d56b1bcad73ebd68e1ac5a8d9c2420560b9ac62a5f15761b21faefc62dc4b94d3ac0293534bf0b089ae162ab37
|
data/lib/celluloid.rb
CHANGED
@@ -8,7 +8,7 @@ if defined?(JRUBY_VERSION) && JRUBY_VERSION == "1.7.3"
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Celluloid
|
11
|
-
VERSION = '0.15.0
|
11
|
+
VERSION = '0.15.0'
|
12
12
|
Error = Class.new StandardError
|
13
13
|
|
14
14
|
extend self # expose all instance methods as singleton methods
|
@@ -416,16 +416,9 @@ module Celluloid
|
|
416
416
|
|
417
417
|
# Timeout on task suspension (eg Sync calls to other actors)
|
418
418
|
def timeout(duration)
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
exception = Task::TimeoutError.new
|
423
|
-
exception.set_backtrace bt
|
424
|
-
task.resume exception
|
425
|
-
end
|
426
|
-
yield
|
427
|
-
ensure
|
428
|
-
timer.cancel if timer
|
419
|
+
Thread.current[:celluloid_actor].timeout(duration) do
|
420
|
+
yield
|
421
|
+
end
|
429
422
|
end
|
430
423
|
|
431
424
|
# Run given block in an exclusive mode: all synchronous calls block the whole
|
data/lib/celluloid/actor.rb
CHANGED
@@ -268,6 +268,19 @@ module Celluloid
|
|
268
268
|
@timers.every(interval) { task(:timer, &block) }
|
269
269
|
end
|
270
270
|
|
271
|
+
def timeout(duration)
|
272
|
+
bt = caller
|
273
|
+
task = Task.current
|
274
|
+
timer = @timers.after(duration) do
|
275
|
+
exception = Task::TimeoutError.new("execution expired")
|
276
|
+
exception.set_backtrace bt
|
277
|
+
task.resume exception
|
278
|
+
end
|
279
|
+
yield
|
280
|
+
ensure
|
281
|
+
timer.cancel if timer
|
282
|
+
end
|
283
|
+
|
271
284
|
class Sleeper
|
272
285
|
def initialize(timers, interval)
|
273
286
|
@timers = timers
|
data/lib/celluloid/tasks.rb
CHANGED
@@ -40,6 +40,7 @@ module Celluloid
|
|
40
40
|
@chain_id = CallChain.current_id
|
41
41
|
|
42
42
|
raise NotActorError, "can't create tasks outside of actors" unless actor
|
43
|
+
raise "can't create tasks inside of tasks" if Thread.current[:celluloid_task]
|
43
44
|
|
44
45
|
create do
|
45
46
|
begin
|
@@ -67,6 +68,7 @@ module Celluloid
|
|
67
68
|
# Suspend the current task, changing the status to the given argument
|
68
69
|
def suspend(status)
|
69
70
|
raise "Cannot suspend while in exclusive mode" if exclusive?
|
71
|
+
raise "Cannot suspend a task from outside of itself" unless Task.current == self
|
70
72
|
|
71
73
|
@status = status
|
72
74
|
|
@@ -91,6 +93,7 @@ module Celluloid
|
|
91
93
|
|
92
94
|
# Resume a suspended task, giving it a value to return if needed
|
93
95
|
def resume(value = nil)
|
96
|
+
raise "Cannot resume a task from inside of a task" if Thread.current[:celluloid_task]
|
94
97
|
deliver(value)
|
95
98
|
nil
|
96
99
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.0
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timers
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|