celluloid 0.12.0.pre3 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/celluloid/actor.rb +2 -2
- data/lib/celluloid/rspec.rb +4 -2
- data/lib/celluloid/tasks/task_thread.rb +8 -9
- data/lib/celluloid/version.rb +1 -1
- data/spec/support/actor_examples.rb +12 -12
- data/spec/support/mailbox_examples.rb +1 -1
- metadata +13 -12
data/lib/celluloid/actor.rb
CHANGED
@@ -191,7 +191,7 @@ module Celluloid
|
|
191
191
|
def run
|
192
192
|
begin
|
193
193
|
while @running
|
194
|
-
if message = @mailbox.receive(
|
194
|
+
if message = @mailbox.receive(timeout_interval)
|
195
195
|
handle_message message
|
196
196
|
else
|
197
197
|
# No message indicates a timeout
|
@@ -277,7 +277,7 @@ module Celluloid
|
|
277
277
|
end
|
278
278
|
|
279
279
|
# How long to wait until the next timer fires
|
280
|
-
def
|
280
|
+
def timeout_interval
|
281
281
|
i1 = @timers.wait_interval
|
282
282
|
i2 = @receivers.wait_interval
|
283
283
|
|
data/lib/celluloid/rspec.rb
CHANGED
@@ -2,5 +2,7 @@ require File.expand_path('../../../spec/support/example_actor_class', __FILE__)
|
|
2
2
|
require File.expand_path('../../../spec/support/actor_examples', __FILE__)
|
3
3
|
require File.expand_path('../../../spec/support/mailbox_examples', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module Celluloid
|
6
|
+
# Timer accuracy enforced by the tests (50ms)
|
7
|
+
TIMER_QUANTUM = 0.05
|
8
|
+
end
|
@@ -17,16 +17,15 @@ module Celluloid
|
|
17
17
|
|
18
18
|
@thread = InternalPool.get do
|
19
19
|
begin
|
20
|
-
|
21
|
-
|
20
|
+
unless @resume_queue.pop.is_a?(Task::TerminatedError)
|
21
|
+
@status = :running
|
22
|
+
Thread.current[:actor] = actor
|
23
|
+
Thread.current[:mailbox] = mailbox
|
24
|
+
Thread.current[:task] = self
|
25
|
+
actor.tasks << self
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
Thread.current[:mailbox] = mailbox
|
26
|
-
Thread.current[:task] = self
|
27
|
-
actor.tasks << self
|
28
|
-
|
29
|
-
yield
|
27
|
+
yield
|
28
|
+
end
|
30
29
|
rescue Task::TerminatedError
|
31
30
|
# Task was explicitly terminated
|
32
31
|
ensure
|
data/lib/celluloid/version.rb
CHANGED
@@ -436,7 +436,7 @@ shared_context "a Celluloid Actor" do |included_module|
|
|
436
436
|
end
|
437
437
|
|
438
438
|
def eat_donuts
|
439
|
-
sleep
|
439
|
+
sleep Celluloid::TIMER_QUANTUM
|
440
440
|
@tasks << 'donuts'
|
441
441
|
end
|
442
442
|
|
@@ -450,7 +450,7 @@ shared_context "a Celluloid Actor" do |included_module|
|
|
450
450
|
actor = subject.new
|
451
451
|
actor.eat_donuts!
|
452
452
|
actor.drink_coffee!
|
453
|
-
sleep
|
453
|
+
sleep Celluloid::TIMER_QUANTUM * 2
|
454
454
|
actor.tasks.should == ['donuts', 'coffee']
|
455
455
|
end
|
456
456
|
end
|
@@ -484,7 +484,7 @@ shared_context "a Celluloid Actor" do |included_module|
|
|
484
484
|
started_at = Time.now
|
485
485
|
|
486
486
|
receiver.receive(interval) { false }.should be_nil
|
487
|
-
(Time.now - started_at).should be_within(
|
487
|
+
(Time.now - started_at).should be_within(Celluloid::TIMER_QUANTUM).of interval
|
488
488
|
end
|
489
489
|
end
|
490
490
|
|
@@ -526,7 +526,7 @@ shared_context "a Celluloid Actor" do |included_module|
|
|
526
526
|
|
527
527
|
# Sleep long enough to ensure we're actually seeing behavior when asleep
|
528
528
|
# but not so long as to delay the test suite unnecessarily
|
529
|
-
interval =
|
529
|
+
interval = Celluloid::TIMER_QUANTUM * 10
|
530
530
|
started_at = Time.now
|
531
531
|
|
532
532
|
future = actor.future(:do_sleep, interval)
|
@@ -534,49 +534,49 @@ shared_context "a Celluloid Actor" do |included_module|
|
|
534
534
|
actor.should be_sleeping
|
535
535
|
|
536
536
|
future.value
|
537
|
-
(Time.now - started_at).should be_within(
|
537
|
+
(Time.now - started_at).should be_within(Celluloid::TIMER_QUANTUM).of interval
|
538
538
|
end
|
539
539
|
|
540
540
|
it "schedules timers which fire in the future" do
|
541
541
|
actor = @klass.new
|
542
542
|
|
543
|
-
interval =
|
543
|
+
interval = Celluloid::TIMER_QUANTUM * 10
|
544
544
|
started_at = Time.now
|
545
545
|
|
546
546
|
timer = actor.fire_after(interval)
|
547
547
|
actor.should_not be_fired
|
548
548
|
|
549
|
-
sleep(interval +
|
549
|
+
sleep(interval + Celluloid::TIMER_QUANTUM) # wonky! #/
|
550
550
|
actor.should be_fired
|
551
551
|
end
|
552
552
|
|
553
553
|
it "schedules recurring timers which fire in the future" do
|
554
554
|
actor = @klass.new
|
555
555
|
|
556
|
-
interval =
|
556
|
+
interval = Celluloid::TIMER_QUANTUM * 10
|
557
557
|
started_at = Time.now
|
558
558
|
|
559
559
|
timer = actor.fire_every(interval)
|
560
560
|
actor.fired.should be == 0
|
561
561
|
|
562
|
-
sleep(interval +
|
562
|
+
sleep(interval + Celluloid::TIMER_QUANTUM) # wonky! #/
|
563
563
|
actor.fired.should be == 1
|
564
564
|
|
565
|
-
2.times { sleep(interval +
|
565
|
+
2.times { sleep(interval + Celluloid::TIMER_QUANTUM) } # wonky! #/
|
566
566
|
actor.fired.should be == 3
|
567
567
|
end
|
568
568
|
|
569
569
|
it "cancels timers before they fire" do
|
570
570
|
actor = @klass.new
|
571
571
|
|
572
|
-
interval =
|
572
|
+
interval = Celluloid::TIMER_QUANTUM * 10
|
573
573
|
started_at = Time.now
|
574
574
|
|
575
575
|
timer = actor.fire_after(interval)
|
576
576
|
actor.should_not be_fired
|
577
577
|
timer.cancel
|
578
578
|
|
579
|
-
sleep(interval +
|
579
|
+
sleep(interval + Celluloid::TIMER_QUANTUM) # wonky! #/
|
580
580
|
actor.should_not be_fired
|
581
581
|
end
|
582
582
|
end
|
@@ -35,6 +35,6 @@ shared_context "a Celluloid Mailbox" do
|
|
35
35
|
started_at = Time.now
|
36
36
|
|
37
37
|
subject.receive(interval) { false }
|
38
|
-
(Time.now - started_at).should be_within(TIMER_QUANTUM).of interval
|
38
|
+
(Time.now - started_at).should be_within(Celluloid::TIMER_QUANTUM).of interval
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.12.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tony Arcieri
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: timers
|
16
|
-
requirement: &
|
16
|
+
requirement: &70127789999080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70127789999080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70127789997960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70127789997960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70127789997400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70127789997400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: benchmark_suite
|
49
|
-
requirement: &
|
49
|
+
requirement: &70127789996720 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70127789996720
|
58
58
|
description: Celluloid enables people to build concurrent programs out of concurrent
|
59
59
|
objects just as easily as they build sequential programs out of sequential objects
|
60
60
|
email:
|
@@ -123,8 +123,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: 1.3.6
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.10
|
127
127
|
signing_key:
|
128
128
|
specification_version: 3
|
129
129
|
summary: Actor-based concurrent object framework for Ruby
|
130
130
|
test_files: []
|
131
|
+
has_rdoc:
|