Protocol

DispatchSourceProtocol

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

Declaration

protocol DispatchSourceProtocol

Overview

You do not adopt this protocol in your objects. Instead, use the makeSignalSource(signal:queue:) method to create an object that adopts this protocol.

Topics

Activating, Suspending, and Resuming a Source

func activate()

Activates the dispatch source.

func suspend()

Suspends the dispatch source.

func resume()

Resumes the dispatch source.

Canceling a Dispatch Source

func cancel()

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

var isCancelled: Bool

Returns a Boolean indicating whether the given dispatch source has been canceled.

func setCancelHandler(handler: DispatchWorkItem)

Sets the cancellation handler block for the dispatch source.

func setCancelHandler(qos: DispatchQoS, flags: DispatchWorkItemFlags, handler: Self.DispatchSourceHandler?)

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

Getting the Dispatch Source Attributes

var handle: UInt

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

var data: UInt

Returns pending data for the dispatch source.

var mask: UInt

Returns the mask of events monitored by the dispatch source.