public function __construct($resource, $autoClose = true)
{
if (!is_resource($resource)) {
throw new InvalidArgumentException('First parameter must be a valid resource.');
}
$this->resource = $resource;
$this->autoClose = $autoClose;
$this->closing = false;
if (function_exists('stream_set_blocking')) {
stream_set_blocking($this->resource, 0);
}
}