{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Cond
(
Cond(..) ,
newZeroCond ,
#if defined(ENABLE_OVERLOADING)
ResolveCondMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
CondBroadcastMethodInfo ,
#endif
condBroadcast ,
#if defined(ENABLE_OVERLOADING)
CondClearMethodInfo ,
#endif
condClear ,
#if defined(ENABLE_OVERLOADING)
CondInitMethodInfo ,
#endif
condInit ,
#if defined(ENABLE_OVERLOADING)
CondSignalMethodInfo ,
#endif
condSignal ,
#if defined(ENABLE_OVERLOADING)
CondWaitMethodInfo ,
#endif
condWait ,
#if defined(ENABLE_OVERLOADING)
CondWaitUntilMethodInfo ,
#endif
condWaitUntil ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import {-# SOURCE #-} qualified GI.GLib.Unions.Mutex as GLib.Mutex
newtype Cond = Cond (SP.ManagedPtr Cond)
deriving (Cond -> Cond -> Bool
(Cond -> Cond -> Bool) -> (Cond -> Cond -> Bool) -> Eq Cond
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cond -> Cond -> Bool
$c/= :: Cond -> Cond -> Bool
== :: Cond -> Cond -> Bool
$c== :: Cond -> Cond -> Bool
Eq)
instance SP.ManagedPtrNewtype Cond where
toManagedPtr :: Cond -> ManagedPtr Cond
toManagedPtr (Cond ManagedPtr Cond
p) = ManagedPtr Cond
p
instance BoxedPtr Cond where
boxedPtrCopy :: Cond -> IO Cond
boxedPtrCopy = \Cond
p -> Cond -> (Ptr Cond -> IO Cond) -> IO Cond
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Cond
p (Int -> Ptr Cond -> IO (Ptr Cond)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
16 (Ptr Cond -> IO (Ptr Cond))
-> (Ptr Cond -> IO Cond) -> Ptr Cond -> IO Cond
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr Cond -> Cond) -> Ptr Cond -> IO Cond
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr Cond -> Cond
Cond)
boxedPtrFree :: Cond -> IO ()
boxedPtrFree = \Cond
x -> Cond -> (Ptr Cond -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr Cond
x Ptr Cond -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr Cond where
boxedPtrCalloc :: IO (Ptr Cond)
boxedPtrCalloc = Int -> IO (Ptr Cond)
forall a. Int -> IO (Ptr a)
callocBytes Int
16
newZeroCond :: MonadIO m => m Cond
newZeroCond :: forall (m :: * -> *). MonadIO m => m Cond
newZeroCond = IO Cond -> m Cond
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Cond -> m Cond) -> IO Cond -> m Cond
forall a b. (a -> b) -> a -> b
$ IO (Ptr Cond)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr Cond) -> (Ptr Cond -> IO Cond) -> IO Cond
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Cond -> Cond) -> Ptr Cond -> IO Cond
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr Cond -> Cond
Cond
instance tag ~ 'AttrSet => Constructible Cond tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr Cond -> Cond) -> [AttrOp Cond tag] -> m Cond
new ManagedPtr Cond -> Cond
_ [AttrOp Cond tag]
attrs = do
Cond
o <- m Cond
forall (m :: * -> *). MonadIO m => m Cond
newZeroCond
Cond -> [AttrOp Cond 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Cond
o [AttrOp Cond tag]
[AttrOp Cond 'AttrSet]
attrs
Cond -> m Cond
forall (m :: * -> *) a. Monad m => a -> m a
return Cond
o
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Cond
type instance O.AttributeList Cond = CondAttributeList
type CondAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_cond_broadcast" g_cond_broadcast ::
Ptr Cond ->
IO ()
condBroadcast ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> m ()
condBroadcast :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Cond -> m ()
condBroadcast Cond
cond = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Cond -> IO ()
g_cond_broadcast Ptr Cond
cond'
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data CondBroadcastMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod CondBroadcastMethodInfo Cond signature where
overloadedMethod = condBroadcast
instance O.OverloadedMethodInfo CondBroadcastMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condBroadcast",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condBroadcast"
})
#endif
foreign import ccall "g_cond_clear" g_cond_clear ::
Ptr Cond ->
IO ()
condClear ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> m ()
condClear :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Cond -> m ()
condClear Cond
cond = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Cond -> IO ()
g_cond_clear Ptr Cond
cond'
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data CondClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod CondClearMethodInfo Cond signature where
overloadedMethod = condClear
instance O.OverloadedMethodInfo CondClearMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condClear",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condClear"
})
#endif
foreign import ccall "g_cond_init" g_cond_init ::
Ptr Cond ->
IO ()
condInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> m ()
condInit :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Cond -> m ()
condInit Cond
cond = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Cond -> IO ()
g_cond_init Ptr Cond
cond'
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data CondInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod CondInitMethodInfo Cond signature where
overloadedMethod = condInit
instance O.OverloadedMethodInfo CondInitMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condInit",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condInit"
})
#endif
foreign import ccall "g_cond_signal" g_cond_signal ::
Ptr Cond ->
IO ()
condSignal ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> m ()
condSignal :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Cond -> m ()
condSignal Cond
cond = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Cond -> IO ()
g_cond_signal Ptr Cond
cond'
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data CondSignalMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod CondSignalMethodInfo Cond signature where
overloadedMethod = condSignal
instance O.OverloadedMethodInfo CondSignalMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condSignal",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condSignal"
})
#endif
foreign import ccall "g_cond_wait" g_cond_wait ::
Ptr Cond ->
Ptr GLib.Mutex.Mutex ->
IO ()
condWait ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> GLib.Mutex.Mutex
-> m ()
condWait :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Cond -> Mutex -> m ()
condWait Cond
cond Mutex
mutex = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Mutex
mutex' <- Mutex -> IO (Ptr Mutex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Mutex
mutex
Ptr Cond -> Ptr Mutex -> IO ()
g_cond_wait Ptr Cond
cond' Ptr Mutex
mutex'
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
Mutex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Mutex
mutex
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data CondWaitMethodInfo
instance (signature ~ (GLib.Mutex.Mutex -> m ()), MonadIO m) => O.OverloadedMethod CondWaitMethodInfo Cond signature where
overloadedMethod = condWait
instance O.OverloadedMethodInfo CondWaitMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condWait",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condWait"
})
#endif
foreign import ccall "g_cond_wait_until" g_cond_wait_until ::
Ptr Cond ->
Ptr GLib.Mutex.Mutex ->
Int64 ->
IO CInt
condWaitUntil ::
(B.CallStack.HasCallStack, MonadIO m) =>
Cond
-> GLib.Mutex.Mutex
-> Int64
-> m Bool
condWaitUntil :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Cond -> Mutex -> Int64 -> m Bool
condWaitUntil Cond
cond Mutex
mutex Int64
endTime = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr Cond
cond' <- Cond -> IO (Ptr Cond)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Cond
cond
Ptr Mutex
mutex' <- Mutex -> IO (Ptr Mutex)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Mutex
mutex
CInt
result <- Ptr Cond -> Ptr Mutex -> Int64 -> IO CInt
g_cond_wait_until Ptr Cond
cond' Ptr Mutex
mutex' Int64
endTime
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
Cond -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Cond
cond
Mutex -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Mutex
mutex
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data CondWaitUntilMethodInfo
instance (signature ~ (GLib.Mutex.Mutex -> Int64 -> m Bool), MonadIO m) => O.OverloadedMethod CondWaitUntilMethodInfo Cond signature where
overloadedMethod = condWaitUntil
instance O.OverloadedMethodInfo CondWaitUntilMethodInfo Cond where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.GLib.Structs.Cond.condWaitUntil",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.26/docs/GI-GLib-Structs-Cond.html#v:condWaitUntil"
})
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveCondMethod (t :: Symbol) (o :: *) :: * where
ResolveCondMethod "broadcast" o = CondBroadcastMethodInfo
ResolveCondMethod "clear" o = CondClearMethodInfo
ResolveCondMethod "init" o = CondInitMethodInfo
ResolveCondMethod "signal" o = CondSignalMethodInfo
ResolveCondMethod "wait" o = CondWaitMethodInfo
ResolveCondMethod "waitUntil" o = CondWaitUntilMethodInfo
ResolveCondMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCondMethod t Cond, O.OverloadedMethod info Cond p) => OL.IsLabel t (Cond -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveCondMethod t Cond, O.OverloadedMethod info Cond p, R.HasField t Cond p) => R.HasField t Cond p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveCondMethod t Cond, O.OverloadedMethodInfo info Cond) => OL.IsLabel t (O.MethodProxy info Cond) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif