Cancellable

open class Cancellable(pointer: <Error class: unknown class><<Error class: unknown class>>)

GCancellable allows operations to be cancelled.

GCancellable is a thread-safe operation cancellation stack used throughout GIO to allow for cancellation of synchronous and asynchronous operations.

Constructors

Link copied to clipboard
constructor()

Creates a new #GCancellable object.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val gioCancellablePointer: <Error class: unknown class><<Error class: unknown class>>

Functions

Link copied to clipboard
open fun cancel()

Will set @cancellable to cancelled, and will emit the #GCancellable::cancelled signal. (However, see the warning about race conditions in the documentation for that signal if you are planning to connect to it.)

Link copied to clipboard
open fun connect(callback: <Error class: unknown class>): <Error class: unknown class>

Convenience function to connect to the #GCancellable::cancelled signal. Also handles the race condition that may happen if the cancellable is cancelled right before connecting.

Link copied to clipboard
fun connectCancelled(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: () -> Unit): <Error class: unknown class>

Emitted when the operation has been cancelled.

Link copied to clipboard
open fun disconnect(handlerId: <Error class: unknown class>)

Disconnects a handler from a cancellable instance similar to g_signal_handler_disconnect(). Additionally, in the event that a signal handler is currently running, this call will block until the handler has finished. Calling this function from a #GCancellable::cancelled signal handler will therefore result in a deadlock.

Link copied to clipboard
open fun getFd(): <Error class: unknown class>

Gets the file descriptor for a cancellable job. This can be used to implement cancellable operations on Unix systems. The returned fd will turn readable when @cancellable is cancelled.

Link copied to clipboard
open fun isCancelled(): Boolean

Checks if a cancellable job has been cancelled.

Link copied to clipboard
open fun makePollfd(pollfd: <Error class: unknown class>): Boolean

Creates a #GPollFD corresponding to @cancellable; this can be passed to g_poll() and used to poll for cancellation. This is useful both for unix systems without a native poll and for portability to windows.

Link copied to clipboard
open fun popCurrent()

Pops @cancellable off the cancellable stack (verifying that @cancellable is on the top of the stack).

Link copied to clipboard
open fun pushCurrent()

Pushes @cancellable onto the cancellable stack. The current cancellable can then be received using g_cancellable_get_current().

Link copied to clipboard
open fun releaseFd()

Releases a resources previously allocated by g_cancellable_get_fd() or g_cancellable_make_pollfd().

Link copied to clipboard
open fun reset()

Resets @cancellable to its uncancelled state.

Link copied to clipboard
open fun setErrorIfCancelled(): <Error class: unknown class><Boolean>

If the @cancellable is cancelled, sets the error to notify that the operation was cancelled.

Link copied to clipboard
open fun sourceNew(): <Error class: unknown class>

Creates a source that triggers if @cancellable is cancelled and calls its callback of type #GCancellableSourceFunc. This is primarily useful for attaching to another (non-cancellable) source with g_source_add_child_source() to add cancellability to it.