flag used for actor stopping insetad of counter
This commit is contained in:
20
tests/actor_suspend_resume.ce
Normal file
20
tests/actor_suspend_resume.ce
Normal file
@@ -0,0 +1,20 @@
|
||||
// Test: actor is suspended by fast timer and resumed under slow timer,
|
||||
// completing the computation correctly.
|
||||
$receiver(function(msg) {
|
||||
if (msg.sum == 12499997500000) {
|
||||
print("PASS: actor suspended and resumed correctly")
|
||||
} else {
|
||||
print(`FAIL: expected 12499997500000, got ${msg.sum}`)
|
||||
}
|
||||
$stop()
|
||||
})
|
||||
|
||||
$start(function(event) {
|
||||
if (event.type == 'greet') {
|
||||
send(event.actor, {count: 5000000, reply: $self})
|
||||
}
|
||||
if (event.type == 'disrupt') {
|
||||
print("FAIL: actor was killed instead of completing")
|
||||
$stop()
|
||||
}
|
||||
}, 'tests/slow_compute_actor')
|
||||
11
tests/slow_compute_actor.ce
Normal file
11
tests/slow_compute_actor.ce
Normal file
@@ -0,0 +1,11 @@
|
||||
// Child actor that does a slow computation and replies with the result
|
||||
$receiver(function(msg) {
|
||||
var n = msg.count
|
||||
var sum = 0
|
||||
var i = 0
|
||||
while (i < n) {
|
||||
sum = sum + i
|
||||
i = i + 1
|
||||
}
|
||||
send(msg.reply, {sum: sum})
|
||||
})
|
||||
Reference in New Issue
Block a user