AsyncWriter
in package
uses
ForbidCloning, ForbidSerialization
FinalYes
This class provides a tool for efficiently writing to a stream asynchronously. A single fiber is used for all writes to the stream, while each write returns a {@see Future} instead of waiting for each write to complete before returning control to the caller.
Table of Contents
Properties
- $destination : WritableStream|null
- $suspension : Suspension<string|int, bool>|null
- $writeQueue : SplQueue<string|int, DeferredFuture, string|null}>
Methods
- __construct() : mixed
- __destruct() : mixed
- __serialize() : never
- __unserialize() : never
- end() : Future<string|int, void>
- Closes the underlying WritableStream once all queued data has been written.
- isWritable() : bool
- write() : Future<string|int, never>
- Queues a chunk of data to be written to the stream, returning a {@see Future} that is completed once the data has been written to the stream or errors if it cannot be written to the stream.
- __clone() : mixed
- dequeue() : void
- send() : Future
Properties
$destination
private
WritableStream|null
$destination
$suspension
private
Suspension<string|int, bool>|null
$suspension
= null
$writeQueue read-only
private
SplQueue<string|int, DeferredFuture, string|null}>
$writeQueue
Methods
__construct()
public
__construct(WritableStream $destination) : mixed
Parameters
- $destination : WritableStream
__destruct()
public
__destruct() : mixed
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
neverend()
Closes the underlying WritableStream once all queued data has been written.
public
end() : Future<string|int, void>
Return values
Future<string|int, void>isWritable()
public
isWritable() : bool
Return values
boolwrite()
Queues a chunk of data to be written to the stream, returning a {@see Future} that is completed once the data has been written to the stream or errors if it cannot be written to the stream.
public
write(string $bytes) : Future<string|int, never>
Parameters
- $bytes : string
Return values
Future<string|int, never>__clone()
protected
final __clone() : mixed
dequeue()
private
static dequeue(SplQueue $writeQueue, WritableStream $destination) : void
Parameters
- $writeQueue : SplQueue
- $destination : WritableStream
send()
private
send(string|null $bytes) : Future
Parameters
- $bytes : string|null