gi-glib-2.0.11: GLib bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.GLib.Structs.Once

Contents

Description

A Once struct controls a one-time initialization function. Any one-time initialization function must have its own unique Once struct.

Synopsis

Exported types

newtype Once Source #

Constructors

Once (ManagedPtr Once) 

Instances

WrappedPtr Once Source # 
(~) AttrOpTag tag AttrSet => Constructible Once tag Source # 

Methods

new :: MonadIO m => (ManagedPtr Once -> Once) -> [AttrOp Once tag] -> m Once #

((~) * info (ResolveOnceMethod t Once), MethodInfo * info Once p) => IsLabel t (Once -> p) Source # 

Methods

fromLabel :: Proxy# Symbol t -> Once -> p #

((~) * info (ResolveOnceMethod t Once), MethodInfo * info Once p) => IsLabelProxy t (Once -> p) Source # 

Methods

fromLabelProxy :: Proxy Symbol t -> Once -> p #

HasAttributeList * Once Source # 
type AttributeList Once Source # 

newZeroOnce :: MonadIO m => m Once Source #

Construct a Once struct initialized to zero.

Methods

initEnter

onceInitEnter Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

location: location of a static initializable variable containing 0

-> m Bool

Returns: True if the initialization section should be entered, False and blocks otherwise

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

onceInitLeave Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Ptr ()

location: location of a static initializable variable containing 0

-> Word64

result: new non-0 value for *valueLocation

-> 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

getOnceRetval :: MonadIO m => Once -> m (Ptr ()) Source #

setOnceRetval :: MonadIO m => Once -> Ptr () -> m () Source #

status