mirror of
https://github.com/danog/byte-stream.git
synced 2024-12-02 09:17:50 +01:00
Allow multiple concurrent buffer calls in Payload
This commit is contained in:
parent
f8ead22238
commit
d2d5b6a7db
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
namespace Amp\ByteStream;
|
namespace Amp\ByteStream;
|
||||||
|
|
||||||
|
use Concurrent\Awaitable;
|
||||||
use Concurrent\Stream\ReadableStream;
|
use Concurrent\Stream\ReadableStream;
|
||||||
|
use Concurrent\Task;
|
||||||
|
|
||||||
class Payload implements ReadableStream
|
class Payload implements ReadableStream
|
||||||
{
|
{
|
||||||
|
/** @var ReadableStream */
|
||||||
private $source;
|
private $source;
|
||||||
|
|
||||||
|
/** @var Awaitable */
|
||||||
|
private $buffer;
|
||||||
|
|
||||||
public function __construct(ReadableStream $source)
|
public function __construct(ReadableStream $source)
|
||||||
{
|
{
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
@ -33,6 +39,8 @@ class Payload implements ReadableStream
|
|||||||
*/
|
*/
|
||||||
final public function buffer(): string
|
final public function buffer(): string
|
||||||
{
|
{
|
||||||
return buffer($this->source);
|
$this->buffer = Task::async('Amp\ByteStream\buffer', $this->source);
|
||||||
|
|
||||||
|
return Task::await($this->buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user