public function handle_back($msg, $state)
{
$state['expected_msg']--;
if (!empty($msg['value'])) {
$state['children'] = array_merge($state['children'], $msg['value']);
}
if ($state['expected_msg'] == 0) {
$pr = $state['parent'];
if ($pr != $this->self()) {
$state['children'][] = $this->getValue($state);
$value_set = $state['children'];
$this->send($pr, new Message('back', array('sender' => $this->self(), 'value' => $value_set)));
} elseif ($pr == $this->self()) {
$r = $this->compute($state['children']);
echo sprintf("proc %s computed: %s\n", $state['name'], $r);
$this->stop();
}
}
return $state;
}