1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-23 06:21:12 +01:00
parallel/lib/Sync/ChannelledSocket.php

36 lines
900 B
PHP
Raw Normal View History

2016-12-29 19:16:04 -06:00
<?php
2017-11-10 11:35:47 -06:00
2016-08-30 18:27:14 -05:00
namespace Amp\Parallel\Sync;
use Amp\ByteStream\ResourceInputStream;
use Amp\ByteStream\ResourceOutputStream;
2017-05-18 09:51:31 +02:00
class ChannelledSocket extends ChannelledStream {
/** @var \Amp\ByteStream\ResourceInputStream */
private $read;
2017-05-18 09:51:31 +02:00
/** @var \Amp\ByteStream\ResourceOutputStream */
private $write;
2017-05-18 09:51:31 +02:00
2016-08-30 18:27:14 -05:00
/**
2016-09-01 18:10:52 -05:00
* @param resource $read Readable stream resource.
* @param resource $write Writable stream resource.
2016-08-30 18:27:14 -05:00
*
* @throws \Error If a stream resource is not given for $resource.
*/
public function __construct($read, $write) {
parent::__construct(
$this->read = new ResourceInputStream($read),
$this->write = new ResourceOutputStream($write)
);
2016-08-30 18:27:14 -05:00
}
2017-05-18 09:51:31 +02:00
2016-08-30 18:27:14 -05:00
/**
* Closes the read and write resource streams.
2016-08-30 18:27:14 -05:00
*/
public function close() {
$this->read->close();
$this->write->close();
2016-08-30 18:27:14 -05:00
}
2017-06-17 18:31:35 +02:00
}