Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype Once = Once (ManagedPtr Once)
- newZeroOnce :: MonadIO m => m Once
- noOnce :: Maybe Once
- onceInitEnter :: (HasCallStack, MonadIO m) => Ptr () -> m Bool
- onceInitLeave :: (HasCallStack, MonadIO m) => Ptr () -> Word64 -> m ()
- clearOnceRetval :: MonadIO m => Once -> m ()
- getOnceRetval :: MonadIO m => Once -> m (Ptr ())
- setOnceRetval :: MonadIO m => Once -> Ptr () -> m ()
- getOnceStatus :: MonadIO m => Once -> m OnceStatus
- setOnceStatus :: MonadIO m => Once -> OnceStatus -> m ()
Exported types
Memory-managed wrapper type.
Instances
WrappedPtr Once Source # | |
Defined in GI.GLib.Structs.Once wrappedPtrCalloc :: IO (Ptr Once) # wrappedPtrCopy :: Once -> IO Once # | |
tag ~ AttrSet => Constructible Once tag Source # | |
Defined in GI.GLib.Structs.Once |
Methods
initEnter
:: (HasCallStack, MonadIO m) | |
=> Ptr () |
|
-> m Bool | Returns: |
Function to be called when starting a critical initialization
section. The argument location
must point to a static
0-initialized variable that will be set to a value other than 0 at
the end of the initialization section. In combination with
onceInitLeave
and the unique address valueLocation
, it can
be ensured that an initialization section will be executed only once
during a program's life time, and that concurrent threads are
blocked until initialization completed. To be used in constructs
like this:
C code
static gsize initialization_value = 0; if (g_once_init_enter (&initialization_value)) { gsize setup_value = 42; // initialization code here g_once_init_leave (&initialization_value, setup_value); } // use initialization_value here
Since: 2.14
initLeave
:: (HasCallStack, MonadIO m) | |
=> Ptr () |
|
-> Word64 |
|
-> m () |
Counterpart to onceInitEnter
. Expects a location of a static
0-initialized initialization variable, and an initialization value
other than 0. Sets the variable to the initialization value, and
releases concurrent threads blocking in onceInitEnter
on this
initialization variable.
Since: 2.14
Properties
retval
the value returned by the call to the function, if status
is OnceStatusReady
clearOnceRetval :: MonadIO m => Once -> m () Source #
Set the value of the “retval
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#retval
getOnceRetval :: MonadIO m => Once -> m (Ptr ()) Source #
Get the value of the “retval
” field.
When overloading is enabled, this is equivalent to
get
once #retval
setOnceRetval :: MonadIO m => Once -> Ptr () -> m () Source #
Set the value of the “retval
” field.
When overloading is enabled, this is equivalent to
set
once [ #retval:=
value ]
status
the status of the Once
getOnceStatus :: MonadIO m => Once -> m OnceStatus Source #
Get the value of the “status
” field.
When overloading is enabled, this is equivalent to
get
once #status
setOnceStatus :: MonadIO m => Once -> OnceStatus -> m () Source #
Set the value of the “status
” field.
When overloading is enabled, this is equivalent to
set
once [ #status:=
value ]