CodeExplorer setHaltCallback example
public function run($offset) { if (is_file($this->destination
) &&
filesize($this->destination
) > 0
) { return new FinishResult($offset,
$this->version->size
);
} $download =
new Download();
$startTime =
microtime(true
);
$download->
setHaltCallback(function D
) use ($startTime) { if (microtime(true
) -
$startTime > 10
) { return true;
} return false;
});
$offset =
$download->
downloadFile($this->version->uri,
$this->destination,
$this->version->size,
$this->version->sha1
);
return new ValidResult($offset,
$this->version->size
);
}}