gi-gst-1.0.18: GI/Gst/Structs/AtomicQueue.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
The 'GI.Gst.Structs.AtomicQueue.AtomicQueue' object implements a queue that can be used from multiple
threads without performing any blocking operations.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gst.Structs.AtomicQueue
(
-- * Exported types
AtomicQueue(..) ,
noAtomicQueue ,
-- * Methods
-- ** length #method:length#
#if ENABLE_OVERLOADING
AtomicQueueLengthMethodInfo ,
#endif
atomicQueueLength ,
-- ** new #method:new#
atomicQueueNew ,
-- ** peek #method:peek#
#if ENABLE_OVERLOADING
AtomicQueuePeekMethodInfo ,
#endif
atomicQueuePeek ,
-- ** pop #method:pop#
#if ENABLE_OVERLOADING
AtomicQueuePopMethodInfo ,
#endif
atomicQueuePop ,
-- ** push #method:push#
#if ENABLE_OVERLOADING
AtomicQueuePushMethodInfo ,
#endif
atomicQueuePush ,
-- ** ref #method:ref#
#if ENABLE_OVERLOADING
AtomicQueueRefMethodInfo ,
#endif
atomicQueueRef ,
-- ** unref #method:unref#
#if ENABLE_OVERLOADING
AtomicQueueUnrefMethodInfo ,
#endif
atomicQueueUnref ,
) 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.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.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
-- | Memory-managed wrapper type.
newtype AtomicQueue = AtomicQueue (ManagedPtr AtomicQueue)
foreign import ccall "gst_atomic_queue_get_type" c_gst_atomic_queue_get_type ::
IO GType
instance BoxedObject AtomicQueue where
boxedType _ = c_gst_atomic_queue_get_type
-- | A convenience alias for `Nothing` :: `Maybe` `AtomicQueue`.
noAtomicQueue :: Maybe AtomicQueue
noAtomicQueue = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList AtomicQueue
type instance O.AttributeList AtomicQueue = AtomicQueueAttributeList
type AtomicQueueAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method AtomicQueue::new
-- method type : Constructor
-- Args : [Arg {argCName = "initial_size", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "initial queue size", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "AtomicQueue"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_new" gst_atomic_queue_new ::
Word32 -> -- initial_size : TBasicType TUInt
IO (Ptr AtomicQueue)
{- |
Create a new atomic queue instance. /@initialSize@/ will be rounded up to the
nearest power of 2 and used as the initial size of the queue.
-}
atomicQueueNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Word32
{- ^ /@initialSize@/: initial queue size -}
-> m AtomicQueue
{- ^ __Returns:__ a new 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
atomicQueueNew initialSize = liftIO $ do
result <- gst_atomic_queue_new initialSize
checkUnexpectedReturnNULL "atomicQueueNew" result
result' <- (wrapBoxed AtomicQueue) result
return result'
#if ENABLE_OVERLOADING
#endif
-- method AtomicQueue::length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_length" gst_atomic_queue_length ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
IO Word32
{- |
Get the amount of items in the queue.
-}
atomicQueueLength ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> m Word32
{- ^ __Returns:__ the number of elements in the queue. -}
atomicQueueLength queue = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
result <- gst_atomic_queue_length queue'
touchManagedPtr queue
return result
#if ENABLE_OVERLOADING
data AtomicQueueLengthMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo AtomicQueueLengthMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueueLength
#endif
-- method AtomicQueue::peek
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_peek" gst_atomic_queue_peek ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
IO (Ptr ())
{- |
Peek the head element of the queue without removing it from the queue.
-}
atomicQueuePeek ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> m (Ptr ())
{- ^ __Returns:__ the head element of /@queue@/ or
'Nothing' when the queue is empty. -}
atomicQueuePeek queue = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
result <- gst_atomic_queue_peek queue'
touchManagedPtr queue
return result
#if ENABLE_OVERLOADING
data AtomicQueuePeekMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m) => O.MethodInfo AtomicQueuePeekMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueuePeek
#endif
-- method AtomicQueue::pop
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TPtr)
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_pop" gst_atomic_queue_pop ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
IO (Ptr ())
{- |
Get the head element of the queue.
-}
atomicQueuePop ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> m (Ptr ())
{- ^ __Returns:__ the head element of /@queue@/ or 'Nothing' when
the queue is empty. -}
atomicQueuePop queue = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
result <- gst_atomic_queue_pop queue'
touchManagedPtr queue
return result
#if ENABLE_OVERLOADING
data AtomicQueuePopMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m) => O.MethodInfo AtomicQueuePopMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueuePop
#endif
-- method AtomicQueue::push
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_push" gst_atomic_queue_push ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
Ptr () -> -- data : TBasicType TPtr
IO ()
{- |
Append /@data@/ to the tail of the queue.
-}
atomicQueuePush ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> Ptr ()
{- ^ /@data@/: the data -}
-> m ()
atomicQueuePush queue data_ = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
gst_atomic_queue_push queue' data_
touchManagedPtr queue
return ()
#if ENABLE_OVERLOADING
data AtomicQueuePushMethodInfo
instance (signature ~ (Ptr () -> m ()), MonadIO m) => O.MethodInfo AtomicQueuePushMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueuePush
#endif
-- method AtomicQueue::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_ref" gst_atomic_queue_ref ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
IO ()
{- |
Increase the refcount of /@queue@/.
-}
atomicQueueRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> m ()
atomicQueueRef queue = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
gst_atomic_queue_ref queue'
touchManagedPtr queue
return ()
#if ENABLE_OVERLOADING
data AtomicQueueRefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AtomicQueueRefMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueueRef
#endif
-- method AtomicQueue::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "queue", argType = TInterface (Name {namespace = "Gst", name = "AtomicQueue"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstAtomicQueue", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_atomic_queue_unref" gst_atomic_queue_unref ::
Ptr AtomicQueue -> -- queue : TInterface (Name {namespace = "Gst", name = "AtomicQueue"})
IO ()
{- |
Unref /@queue@/ and free the memory when the refcount reaches 0.
-}
atomicQueueUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
AtomicQueue
{- ^ /@queue@/: a 'GI.Gst.Structs.AtomicQueue.AtomicQueue' -}
-> m ()
atomicQueueUnref queue = liftIO $ do
queue' <- unsafeManagedPtrGetPtr queue
gst_atomic_queue_unref queue'
touchManagedPtr queue
return ()
#if ENABLE_OVERLOADING
data AtomicQueueUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AtomicQueueUnrefMethodInfo AtomicQueue signature where
overloadedMethod _ = atomicQueueUnref
#endif
#if ENABLE_OVERLOADING
type family ResolveAtomicQueueMethod (t :: Symbol) (o :: *) :: * where
ResolveAtomicQueueMethod "length" o = AtomicQueueLengthMethodInfo
ResolveAtomicQueueMethod "peek" o = AtomicQueuePeekMethodInfo
ResolveAtomicQueueMethod "pop" o = AtomicQueuePopMethodInfo
ResolveAtomicQueueMethod "push" o = AtomicQueuePushMethodInfo
ResolveAtomicQueueMethod "ref" o = AtomicQueueRefMethodInfo
ResolveAtomicQueueMethod "unref" o = AtomicQueueUnrefMethodInfo
ResolveAtomicQueueMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAtomicQueueMethod t AtomicQueue, O.MethodInfo info AtomicQueue p) => OL.IsLabel t (AtomicQueue -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif