ChannelWriter
public class ChannelWriter<T>
The ChannelWriter class writes values to a channel.
It’s a reference type so Channels have a common object to add handlers to.
-
Initializes an empty ChannelWriter
Declaration
Swift
public init() -
Declaration
Swift
public func addHandler(handler: T -> ())Parameters
handlerA function to be called when a value is written.
-
Asynchronously and concurrently writes a value to all attached handlers.
Note
If the queue passed is not concurrent, handlers will not be called concurrently.
Declaration
Swift
public func write( value: T, queue: DispatchQueue = Dispatch.globalQueue ) -> Future<()>Parameters
valueThe value to write
queueThe queue to execute handlers on
Return Value
A
Futurethat will complete when all handlers have exited. -
A
Channelwhich will receive values written to this writer.Declaration
Swift
public var channel: Channel<T>
ChannelWriter Class Reference