{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.RWLock
(
RWLock(..) ,
newZeroRWLock ,
#if defined(ENABLE_OVERLOADING)
ResolveRWLockMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
RWLockClearMethodInfo ,
#endif
rWLockClear ,
#if defined(ENABLE_OVERLOADING)
RWLockInitMethodInfo ,
#endif
rWLockInit ,
#if defined(ENABLE_OVERLOADING)
RWLockReaderLockMethodInfo ,
#endif
rWLockReaderLock ,
#if defined(ENABLE_OVERLOADING)
RWLockReaderTrylockMethodInfo ,
#endif
rWLockReaderTrylock ,
#if defined(ENABLE_OVERLOADING)
RWLockReaderUnlockMethodInfo ,
#endif
rWLockReaderUnlock ,
#if defined(ENABLE_OVERLOADING)
RWLockWriterLockMethodInfo ,
#endif
rWLockWriterLock ,
#if defined(ENABLE_OVERLOADING)
RWLockWriterTrylockMethodInfo ,
#endif
rWLockWriterTrylock ,
#if defined(ENABLE_OVERLOADING)
RWLockWriterUnlockMethodInfo ,
#endif
rWLockWriterUnlock ,
) 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.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.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
newtype RWLock = RWLock (SP.ManagedPtr RWLock)
deriving (RWLock -> RWLock -> Bool
(RWLock -> RWLock -> Bool)
-> (RWLock -> RWLock -> Bool) -> Eq RWLock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RWLock -> RWLock -> Bool
$c/= :: RWLock -> RWLock -> Bool
== :: RWLock -> RWLock -> Bool
$c== :: RWLock -> RWLock -> Bool
Eq)
instance SP.ManagedPtrNewtype RWLock where
toManagedPtr :: RWLock -> ManagedPtr RWLock
toManagedPtr (RWLock ManagedPtr RWLock
p) = ManagedPtr RWLock
p
instance BoxedPtr RWLock where
boxedPtrCopy :: RWLock -> IO RWLock
boxedPtrCopy = \RWLock
p -> RWLock -> (Ptr RWLock -> IO RWLock) -> IO RWLock
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr RWLock
p (Int -> Ptr RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
16 (Ptr RWLock -> IO (Ptr RWLock))
-> (Ptr RWLock -> IO RWLock) -> Ptr RWLock -> IO RWLock
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr RWLock -> RWLock) -> Ptr RWLock -> IO RWLock
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr RWLock -> RWLock
RWLock)
boxedPtrFree :: RWLock -> IO ()
boxedPtrFree = \RWLock
x -> RWLock -> (Ptr RWLock -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr RWLock
x Ptr RWLock -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr RWLock where
boxedPtrCalloc :: IO (Ptr RWLock)
boxedPtrCalloc = Int -> IO (Ptr RWLock)
forall a. Int -> IO (Ptr a)
callocBytes Int
16
newZeroRWLock :: MonadIO m => m RWLock
newZeroRWLock :: m RWLock
newZeroRWLock = IO RWLock -> m RWLock
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RWLock -> m RWLock) -> IO RWLock -> m RWLock
forall a b. (a -> b) -> a -> b
$ IO (Ptr RWLock)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr RWLock) -> (Ptr RWLock -> IO RWLock) -> IO RWLock
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr RWLock -> RWLock) -> Ptr RWLock -> IO RWLock
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr RWLock -> RWLock
RWLock
instance tag ~ 'AttrSet => Constructible RWLock tag where
new :: (ManagedPtr RWLock -> RWLock) -> [AttrOp RWLock tag] -> m RWLock
new ManagedPtr RWLock -> RWLock
_ [AttrOp RWLock tag]
attrs = do
RWLock
o <- m RWLock
forall (m :: * -> *). MonadIO m => m RWLock
newZeroRWLock
RWLock -> [AttrOp RWLock 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set RWLock
o [AttrOp RWLock tag]
[AttrOp RWLock 'AttrSet]
attrs
RWLock -> m RWLock
forall (m :: * -> *) a. Monad m => a -> m a
return RWLock
o
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList RWLock
type instance O.AttributeList RWLock = RWLockAttributeList
type RWLockAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_rw_lock_clear" g_rw_lock_clear ::
Ptr RWLock ->
IO ()
rWLockClear ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockClear :: RWLock -> m ()
rWLockClear RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_clear Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockClearMethodInfo RWLock signature where
overloadedMethod = rWLockClear
#endif
foreign import ccall "g_rw_lock_init" g_rw_lock_init ::
Ptr RWLock ->
IO ()
rWLockInit ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockInit :: RWLock -> m ()
rWLockInit RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_init Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockInitMethodInfo RWLock signature where
overloadedMethod = rWLockInit
#endif
foreign import ccall "g_rw_lock_reader_lock" g_rw_lock_reader_lock ::
Ptr RWLock ->
IO ()
rWLockReaderLock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockReaderLock :: RWLock -> m ()
rWLockReaderLock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_reader_lock Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockReaderLockMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockReaderLockMethodInfo RWLock signature where
overloadedMethod = rWLockReaderLock
#endif
foreign import ccall "g_rw_lock_reader_trylock" g_rw_lock_reader_trylock ::
Ptr RWLock ->
IO CInt
rWLockReaderTrylock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m Bool
rWLockReaderTrylock :: RWLock -> m Bool
rWLockReaderTrylock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
CInt
result <- Ptr RWLock -> IO CInt
g_rw_lock_reader_trylock Ptr RWLock
rwLock'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data RWLockReaderTrylockMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RWLockReaderTrylockMethodInfo RWLock signature where
overloadedMethod = rWLockReaderTrylock
#endif
foreign import ccall "g_rw_lock_reader_unlock" g_rw_lock_reader_unlock ::
Ptr RWLock ->
IO ()
rWLockReaderUnlock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockReaderUnlock :: RWLock -> m ()
rWLockReaderUnlock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_reader_unlock Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockReaderUnlockMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockReaderUnlockMethodInfo RWLock signature where
overloadedMethod = rWLockReaderUnlock
#endif
foreign import ccall "g_rw_lock_writer_lock" g_rw_lock_writer_lock ::
Ptr RWLock ->
IO ()
rWLockWriterLock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockWriterLock :: RWLock -> m ()
rWLockWriterLock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_writer_lock Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockWriterLockMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockWriterLockMethodInfo RWLock signature where
overloadedMethod = rWLockWriterLock
#endif
foreign import ccall "g_rw_lock_writer_trylock" g_rw_lock_writer_trylock ::
Ptr RWLock ->
IO CInt
rWLockWriterTrylock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m Bool
rWLockWriterTrylock :: RWLock -> m Bool
rWLockWriterTrylock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
CInt
result <- Ptr RWLock -> IO CInt
g_rw_lock_writer_trylock Ptr RWLock
rwLock'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data RWLockWriterTrylockMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RWLockWriterTrylockMethodInfo RWLock signature where
overloadedMethod = rWLockWriterTrylock
#endif
foreign import ccall "g_rw_lock_writer_unlock" g_rw_lock_writer_unlock ::
Ptr RWLock ->
IO ()
rWLockWriterUnlock ::
(B.CallStack.HasCallStack, MonadIO m) =>
RWLock
-> m ()
rWLockWriterUnlock :: RWLock -> m ()
rWLockWriterUnlock RWLock
rwLock = 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 RWLock
rwLock' <- RWLock -> IO (Ptr RWLock)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr RWLock
rwLock
Ptr RWLock -> IO ()
g_rw_lock_writer_unlock Ptr RWLock
rwLock'
RWLock -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr RWLock
rwLock
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RWLockWriterUnlockMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RWLockWriterUnlockMethodInfo RWLock signature where
overloadedMethod = rWLockWriterUnlock
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveRWLockMethod (t :: Symbol) (o :: *) :: * where
ResolveRWLockMethod "clear" o = RWLockClearMethodInfo
ResolveRWLockMethod "init" o = RWLockInitMethodInfo
ResolveRWLockMethod "readerLock" o = RWLockReaderLockMethodInfo
ResolveRWLockMethod "readerTrylock" o = RWLockReaderTrylockMethodInfo
ResolveRWLockMethod "readerUnlock" o = RWLockReaderUnlockMethodInfo
ResolveRWLockMethod "writerLock" o = RWLockWriterLockMethodInfo
ResolveRWLockMethod "writerTrylock" o = RWLockWriterTrylockMethodInfo
ResolveRWLockMethod "writerUnlock" o = RWLockWriterUnlockMethodInfo
ResolveRWLockMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRWLockMethod t RWLock, O.MethodInfo info RWLock p) => OL.IsLabel t (RWLock -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif