Protocol

DispatchSourceProtocol

Defines a common set of properties and methods that are shared with all dispatch source types.

Topics

Instance Properties

var data: UInt

Returns pending data for the dispatch source.

var handle: UInt

Returns the underlying system handle associated with the specified dispatch source.

var isCancelled: Bool

Returns whether the given dispatch source has been canceled.

var mask: UInt

Returns the mask of events monitored by the dispatch source.

Instance Methods

func activate()

Activates the dispatch source.

func cancel()

Asynchronously cancels the dispatch source, preventing any further invocation of its event handler block.

func resume()

Resumes the dispatch source.

func setCancelHandler(handler: DispatchWorkItem)

Sets the cancellation handler block for the dispatch source with the specified quality of service class and work item options.

func setEventHandler(handler: DispatchWorkItem)

Sets the event handler work item for the dispatch source.

func setEventHandler(qos: DispatchQoS, flags: DispatchWorkItemFlags, handler: DispatchSourceProtocol.DispatchSourceHandler?)

Sets the event handler block for the dispatch source with the specified quality of service class and work item options.

func setRegistrationHandler(handler: DispatchWorkItem)

Sets the registration handler work item for the dispatch source.

func setRegistrationHandler(qos: DispatchQoS, flags: DispatchWorkItemFlags, handler: DispatchSourceProtocol.DispatchSourceHandler?)

Sets the registration handler block for the dispatch source with the specified quality of service class and work item options.

func suspend()

Suspends the dispatch source.

See Also

Managing Dispatch Sources

class DispatchSource

DispatchSource provides an interface for monitoring low-level system objects such as Mach ports, Unix descriptors, Unix signals, and VFS nodes for activity and submitting event handlers to dispatch queues for asynchronous processing when such activity occurs.

protocol DispatchSourceFileSystemObject

A dispatch source that monitors a file descriptor for events defined by DispatchSource.FileSystemEvent. The handle is a file descriptor (Int32).

protocol DispatchSourceMachSend

A dispatch source that monitors a Mach port for dead name notifications, indicating that a send right no longer has any corresponding receive right. The handle is a Mach port with a send or send-once right (mach_port_t).

protocol DispatchSourceMachReceive

A dispatch source that monitors a Mach port for pending messages. The handle is a Mach port with a receive right (mach_port_t).

protocol DispatchSourceMemoryPressure

A dispatch source that monitors the system for changes in memory pressure condition.

protocol DispatchSourceProcess

A dispatch source that monitors an external process for events defined by DispatchSource.ProcessEvent. The handle is a process identifier (pid_t).

protocol DispatchSourceTimer

A dispatch source that submits the event handler block based on a timer.

protocol DispatchSourceUserDataAdd

A dispatch source that coalesces data obtained via calls to calls to the add(data:) method.

protocol DispatchSourceUserDataOr

A dispatch source that coalesces data obtained via calls to the or(data:) method.

protocol DispatchSourceSignal

A dispatch source that monitors the current process for Unix signals.