Cancellation

## Cancellation Cancellation — halt in-progress operations |

## Synopsis

    MateVFSCancellation * mate_vfs_cancellation_new       (void);
    void                mate_vfs_cancellation_destroy      (MateVFSCancellation *cancellation);
    void                mate_vfs_cancellation_cancel       (MateVFSCancellation *cancellation);
    gboolean            mate_vfs_cancellation_check        (MateVFSCancellation *cancellation);
    void                mate_vfs_cancellation_ack          (MateVFSCancellation *cancellation);
    gint                mate_vfs_cancellation_get_fd       (MateVFSCancellation *cancellation);

## Description

## Details

### mate_vfs_cancellation_new ()

    MateVFSCancellation * mate_vfs_cancellation_new       (void);

Create a new MateVFSCancellation object for reporting cancellation to a mate-vfs module.

Returns : | A pointer to the new MateVFSCancellation object.

### mate_vfs_cancellation_destroy ()

    void                mate_vfs_cancellation_destroy      (MateVFSCancellation *cancellation);

Destroy `cancellation`.

`cancellation` : | a MateVFSCancellation object.

### mate_vfs_cancellation_cancel ()

    void                mate_vfs_cancellation_cancel       (MateVFSCancellation *cancellation);

Send a cancellation request through `cancellation`.

If called on a different thread than the one handling idle callbacks, there is a small race condition where the operation finished callback will be called even if you cancelled the operation. Its the apps responsibility to handle this. See `mate_vfs_async_cancel()` for more discussion about this.

`cancellation` : | a MateVFSCancellation object.

### mate_vfs_cancellation_check ()

    gboolean            mate_vfs_cancellation_check        (MateVFSCancellation *cancellation);

Check for pending cancellation.

`cancellation` : | a MateVFSCancellation object.
Returns : | `TRUE` if the operation should be interrupted.

### mate_vfs_cancellation_ack ()

    void                mate_vfs_cancellation_ack          (MateVFSCancellation *cancellation);

Acknowledge a cancellation. This should be called if `mate_vfs_cancellation_check()` returns `TRUE` or if `select()` reports that input is available on the file descriptor returned by `mate_vfs_cancellation_get_fd()`.

`cancellation` : | a MateVFSCancellation object.

### mate_vfs_cancellation_get_fd ()

    gint                mate_vfs_cancellation_get_fd       (MateVFSCancellation *cancellation);

Get a file descriptor -based notificator for `cancellation`. When `cancellation` receives a cancellation request, a character will be made available on the returned file descriptor for input.

This is very useful for detecting cancellation during I/O operations: you can use the `select()` call to check for available input/output on the file you are reading/writing, and on the notificator's file descriptor at the same time. If a data is available on the notificator's file descriptor, you know you have to cancel the read/write operation.

`cancellation` : | a MateVFSCancellation object.
Returns : | the notificator's file descriptor, or -1 if starved of file descriptors.