gi-glib-2.0.30: GLib bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.GLib.Structs.SourceFuncs

Contents

- Exported types
- Methods
- Properties
  - check
  - finalize
  - prepare

Description

The `GSourceFuncs` struct contains a table of functions used to handle event sources in a generic manner.

For idle sources, the prepare and check functions always return `True` to indicate that the source is always ready to be processed. The prepare function also returns a timeout value of 0 to ensure that the `poll()` call doesn't block (since that would be time wasted which could have been spent running the idle function).

For timeout sources, the prepare and check functions both return `True` if the timeout interval has expired. The prepare function also returns a timeout value to ensure that the `poll()` call doesn't block too long and miss the next timeout.

For file descriptor sources, the prepare function typically returns `False`, since it must wait until `poll()` has been called before it knows whether any events need to be processed. It sets the returned timeout to -1 to indicate that it doesn't mind how long the `poll()` call blocks. In the check function, it tests the results of the `poll()` call to see if the required condition has been met, and returns `True` if so.

Synopsis

- newtype SourceFuncs = SourceFuncs (ManagedPtr SourceFuncs)
- newZeroSourceFuncs :: MonadIO m => m SourceFuncs
- clearSourceFuncsCheck :: MonadIO m => SourceFuncs -> m ()
- getSourceFuncsCheck :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsCheckFunc)
- setSourceFuncsCheck :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsCheckFunc -> m ()
- clearSourceFuncsFinalize :: MonadIO m => SourceFuncs -> m ()
- getSourceFuncsFinalize :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsFinalizeFunc)
- setSourceFuncsFinalize :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsFinalizeFunc -> m ()
- clearSourceFuncsPrepare :: MonadIO m => SourceFuncs -> m ()
- getSourceFuncsPrepare :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsPrepareFunc)
- setSourceFuncsPrepare :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsPrepareFunc -> m ()

# Exported types

newtype SourceFuncs Source #

Memory-managed wrapper type.

Constructors

SourceFuncs (ManagedPtr SourceFuncs) |

#### Instances

Instances details

Eq SourceFuncs Source # |
Instance details Defined in GI.GLib.Structs.SourceFuncs Methods (==) :: SourceFuncs -> SourceFuncs -> Bool Source # (/=) :: SourceFuncs -> SourceFuncs -> Bool Source #
BoxedPtr SourceFuncs Source # |
Instance details Defined in GI.GLib.Structs.SourceFuncs Methods boxedPtrCopy :: SourceFuncs -> IO SourceFuncs Source # boxedPtrFree :: SourceFuncs -> IO () Source #
CallocPtr SourceFuncs Source # |
Instance details Defined in GI.GLib.Structs.SourceFuncs Methods boxedPtrCalloc :: IO (Ptr SourceFuncs) Source #
ManagedPtrNewtype SourceFuncs Source # |
Instance details Defined in GI.GLib.Structs.SourceFuncs Methods toManagedPtr :: SourceFuncs -> ManagedPtr SourceFuncs Source #
tag ~ 'AttrSet => Constructible SourceFuncs tag Source # |
Instance details Defined in GI.GLib.Structs.SourceFuncs Methods new :: MonadIO m => (ManagedPtr SourceFuncs -> SourceFuncs) -> [AttrOp SourceFuncs tag] -> m SourceFuncs Source #

newZeroSourceFuncs :: MonadIO m => m SourceFuncs Source #

Construct a `SourceFuncs` struct initialized to zero.

# Methods

# Properties

## check

Called after all the file descriptors are polled. The source should return `True` if it is ready to be dispatched. Note that some time may have passed since the previous prepare function was called, so the source should be checked again here. Since 2.36 this may be `Nothing`, in which case the effect is as if the function always returns `False`.

clearSourceFuncsCheck :: MonadIO m => SourceFuncs -> m () Source #

Set the value of the “`check`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #check

getSourceFuncsCheck :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsCheckFunc) Source #

Get the value of the “`check`” field. When overloading is enabled, this is equivalent to

    get sourceFuncs #check

setSourceFuncsCheck :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsCheckFunc -> m () Source #

Set the value of the “`check`” field. When overloading is enabled, this is equivalent to

    set sourceFuncs [ #check := value ]

## finalize

Called when the source is finalized. At this point, the source will have been destroyed, had its callback cleared, and have been removed from its `MainContext`, but it will still have its final reference count, so methods can be called on it from within this function. This may be `Nothing`, in which case the effect is as if the function does nothing and returns.

clearSourceFuncsFinalize :: MonadIO m => SourceFuncs -> m () Source #

Set the value of the “`finalize`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #finalize

getSourceFuncsFinalize :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsFinalizeFunc) Source #

Get the value of the “`finalize`” field. When overloading is enabled, this is equivalent to

    get sourceFuncs #finalize

setSourceFuncsFinalize :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsFinalizeFunc -> m () Source #

Set the value of the “`finalize`” field. When overloading is enabled, this is equivalent to

    set sourceFuncs [ #finalize := value ]

## prepare

Called before all the file descriptors are polled. If the source can determine that it is ready here (without waiting for the results of the `poll()` call) it should return `True`. It can also return a `timeout_` value which should be the maximum timeout (in milliseconds) which should be passed to the `poll()` call. The actual timeout used will be -1 if all sources returned -1, or it will be the minimum of all the `timeout_` values returned which were >= 0. Since 2.36 this may be `Nothing`, in which case the effect is as if the function always returns `False` with a timeout of -1. If `prepare` returns a timeout and the source also has a ready time set, then the lower of the two will be used.

clearSourceFuncsPrepare :: MonadIO m => SourceFuncs -> m () Source #

Set the value of the “`prepare`” field to `Nothing`. When overloading is enabled, this is equivalent to

    clear #prepare

getSourceFuncsPrepare :: MonadIO m => SourceFuncs -> m (Maybe SourceFuncsPrepareFunc) Source #

Get the value of the “`prepare`” field. When overloading is enabled, this is equivalent to

    get sourceFuncs #prepare

setSourceFuncsPrepare :: MonadIO m => SourceFuncs -> FunPtr C_SourceFuncsPrepareFunc -> m () Source #

Set the value of the “`prepare`” field. When overloading is enabled, this is equivalent to

    set sourceFuncs [ #prepare := value ]