Contents

xpc_connection_cancel(_:)

Cancels the connection and ensures that its event handler doesn’t fire again.

Declaration

func xpc_connection_cancel(_ connection: xpc_connection_t)

Parameters

  • connection:

    The connection object which is to be manipulated.

Discussion

After this call, any messages that have not yet been sent will be discarded, and the connection will be unwound. If there are messages that are awaiting replies, they will have their reply handlers invoked with the XPC_ERROR_CONNECTION_INVALID error.

Cancellation is asynchronous and non-preemptive and therefore this method will not interrupt the execution of an already-running event handler block. If the event handler is executing at the time of this call, it will finish, and then the connection will be canceled, causing a final invocation of the event handler to be scheduled with the XPC_ERROR_CONNECTION_INVALID error. After that invocation, there will be no further invocations of the event handler.

The XPC runtime guarantees this non-preemptiveness even for concurrent target queues.

See Also

Life cycle