public function doctrine($conn, $command)
{
// switch to the new runlevel
$result = $this->synchronized(function ($self, $cmd) {
// wait till the previous commands has been finished
while ($self->locked === true) {
sleep(1);
}
// set connection and command name
$self->command = DoctrineCommand::COMMAND;
// lock process
$self->locked = true;
$self->params = $cmd;
$self->result = null;
// notify the AS to execute the command
$self->notify();
// wait for the result of the command
while ($self->result == null) {
$self->wait(10000);
}
// return the result
return $self->result;
}, $this, $command);
// write the result to the output
$conn->write($result);
}