Generic Instance Method

sync(flags:execute:)

Submits a work item for execution using the specified attributes and returns the results from that item after it finishes executing.

Declaration

func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T

Parameters

flags

Additional attributes to apply when executing the block. For a list of possible values, see DispatchWorkItemFlags.

work

The work item containing the work to perform. The block encapsulated by the work item should return a result, which is then returned by this method. For information on how to create this work item, see DispatchWorkItem.

Return Value

The return value of the item in the work parameter.

See Also

Executing Tasks Synchronously

func sync(execute: DispatchWorkItem)

Submits a work item for execution on the current queue and returns after that block finishes executing.

func sync(execute: () -> Void)

Submits a block object for execution and returns after that block finishes executing.

func sync<T>(execute: () -> T) -> T

Submits a work item for execution and returns the results from that item after it finishes executing.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software