Documentation

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

$writeQueue read-only

private SplQueue<string|int, DeferredFuture, string|null}> $writeQueue

Methods

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : never
Parameters
$data : array<string|int, mixed>
Return values
never

end()

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
bool

write()

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>

        
On this page

Search results