{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) The 'GI.Gst.Structs.AtomicQueue.AtomicQueue' object implements a queue that can be used from multiple threads without performing any blocking operations. -} module GI.Gst.Structs.AtomicQueue ( -- * Exported types AtomicQueue(..) , noAtomicQueue , -- * Methods -- ** length #method:length# AtomicQueueLengthMethodInfo , atomicQueueLength , -- ** new #method:new# atomicQueueNew , -- ** peek #method:peek# AtomicQueuePeekMethodInfo , atomicQueuePeek , -- ** pop #method:pop# AtomicQueuePopMethodInfo , atomicQueuePop , -- ** push #method:push# AtomicQueuePushMethodInfo , atomicQueuePush , -- ** ref #method:ref# AtomicQueueRefMethodInfo , atomicQueueRef , -- ** unref #method:unref# AtomicQueueUnrefMethodInfo , 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.GError as B.GError import qualified Data.GI.Base.GVariant as B.GVariant import qualified Data.GI.Base.GParamSpec as B.GParamSpec import qualified Data.GI.Base.CallStack as B.CallStack 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 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 noAtomicQueue :: Maybe AtomicQueue noAtomicQueue = Nothing instance O.HasAttributeList AtomicQueue type instance O.AttributeList AtomicQueue = AtomicQueueAttributeList type AtomicQueueAttributeList = ('[ ] :: [(Symbol, *)]) -- 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' -- 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 data AtomicQueueLengthMethodInfo instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo AtomicQueueLengthMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueueLength -- 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 data AtomicQueuePeekMethodInfo instance (signature ~ (m (Ptr ())), MonadIO m) => O.MethodInfo AtomicQueuePeekMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueuePeek -- 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 data AtomicQueuePopMethodInfo instance (signature ~ (m (Ptr ())), MonadIO m) => O.MethodInfo AtomicQueuePopMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueuePop -- 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 () data AtomicQueuePushMethodInfo instance (signature ~ (Ptr () -> m ()), MonadIO m) => O.MethodInfo AtomicQueuePushMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueuePush -- 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 () data AtomicQueueRefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AtomicQueueRefMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueueRef -- 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 () data AtomicQueueUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo AtomicQueueUnrefMethodInfo AtomicQueue signature where overloadedMethod _ = atomicQueueUnref 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) => O.IsLabelProxy t (AtomicQueue -> p) where fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveAtomicQueueMethod t AtomicQueue, O.MethodInfo info AtomicQueue p) => O.IsLabel t (AtomicQueue -> p) where fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #endif