gi-glib-0.2.44.12: GI/GLib/Unions/Mutex.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}
module GI.GLib.Unions.Mutex
(
-- * Exported types
Mutex(..) ,
noMutex ,
-- * Methods
-- ** mutexClear
mutexClear ,
-- ** mutexInit
mutexInit ,
-- ** mutexLock
mutexLock ,
-- ** mutexTrylock
mutexTrylock ,
-- ** mutexUnlock
mutexUnlock ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GLib.Types
import GI.GLib.Callbacks
newtype Mutex = Mutex (ForeignPtr Mutex)
noMutex :: Maybe Mutex
noMutex = Nothing
-- method Mutex::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_mutex_clear" g_mutex_clear ::
Ptr Mutex -> -- _obj : TInterface "GLib" "Mutex"
IO ()
mutexClear ::
(MonadIO m) =>
Mutex -> -- _obj
m ()
mutexClear _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_mutex_clear _obj'
touchManagedPtr _obj
return ()
-- method Mutex::init
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_mutex_init" g_mutex_init ::
Ptr Mutex -> -- _obj : TInterface "GLib" "Mutex"
IO ()
mutexInit ::
(MonadIO m) =>
Mutex -> -- _obj
m ()
mutexInit _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_mutex_init _obj'
touchManagedPtr _obj
return ()
-- method Mutex::lock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_mutex_lock" g_mutex_lock ::
Ptr Mutex -> -- _obj : TInterface "GLib" "Mutex"
IO ()
mutexLock ::
(MonadIO m) =>
Mutex -> -- _obj
m ()
mutexLock _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_mutex_lock _obj'
touchManagedPtr _obj
return ()
-- method Mutex::trylock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "g_mutex_trylock" g_mutex_trylock ::
Ptr Mutex -> -- _obj : TInterface "GLib" "Mutex"
IO CInt
mutexTrylock ::
(MonadIO m) =>
Mutex -> -- _obj
m Bool
mutexTrylock _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_mutex_trylock _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
-- method Mutex::unlock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Mutex", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_mutex_unlock" g_mutex_unlock ::
Ptr Mutex -> -- _obj : TInterface "GLib" "Mutex"
IO ()
mutexUnlock ::
(MonadIO m) =>
Mutex -> -- _obj
m ()
mutexUnlock _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_mutex_unlock _obj'
touchManagedPtr _obj
return ()