/**
* {@inheritdoc}
*/
public function close()
{
if ($this->open && $this->worker->isRunning()) {
$coroutine = new Coroutine($this->worker->enqueue(new Internal\FileTask('fclose', [], $this->id)));
$coroutine->done(null, [$this->worker, 'kill']);
}
if (!$this->queue->isEmpty()) {
$exception = new FileException('The file was closed.');
do {
$this->queue->shift()->cancel($exception);
} while (!$this->queue->isEmpty());
}
$this->open = false;
$this->writable = false;
}