An object that manages operations on a file descriptor using either stream-based or random-access semantics.


class DispatchIO : DispatchObject


Creating a Dispatch I/O Object

init?(type: DispatchIO.StreamType, path: UnsafePointer<Int8>, oflag: Int32, mode: mode_t, queue: DispatchQueue, cleanupHandler: (Int32) -> Void)

Creates a new I/O channel that accesses the file at the specified path, potentially creating that file in the process.

enum DispatchIO.StreamType

The semantics for accessing the contents of a file descriptor.

Reading from the File

Closing the File

func close(flags: DispatchIO.CloseFlags)

Closes the channel to new read and write operations.

struct DispatchIO.CloseFlags

Additional flags to use when closing an I/O channel.

Managing the File Descriptor

var fileDescriptor: Int32

Returns the file descriptor associated with the specified channel.

func setLimit(highWater: Int)

Sets the maximum number of bytes to process before enqueueing a handler block.

func setLimit(lowWater: Int)

Sets the minimum number of bytes to process before enqueueing a handler block.

func setInterval(interval: DispatchTimeInterval, flags: DispatchIO.IntervalFlags)

Sets the interval, in nanoseconds, at which to invoke the I/O handlers for the channel.

Synchronizing File Operations

func barrier(execute: () -> Void)

Schedules a barrier operation on the specified channel.


Inherits From

Conforms To

See Also

System Event Monitoring

class DispatchSource

An object that coordinates the processing of specific low-level system events, such as file-system events, timers, and UNIX signals.

struct DispatchData

An object that manages a memory-based data buffer and exposes it as a contiguous block of memory.

struct DispatchDataIterator

A byte-by-byte iterator over the contents of a dispatch data object.