{- |
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 GAsyncQueue struct is an opaque data structure which represents
an asynchronous queue. It should only be accessed through the
g_async_queue_* functions.
-}

module GI.GLib.Structs.AsyncQueue
    ( 

-- * Exported types
    AsyncQueue(..)                          ,
    noAsyncQueue                            ,


 -- * Methods
-- ** asyncQueueLength
    asyncQueueLength                        ,


-- ** asyncQueueLengthUnlocked
    asyncQueueLengthUnlocked                ,


-- ** asyncQueueLock
    asyncQueueLock                          ,


-- ** asyncQueuePush
    asyncQueuePush                          ,


-- ** asyncQueuePushFront
    asyncQueuePushFront                     ,


-- ** asyncQueuePushFrontUnlocked
    asyncQueuePushFrontUnlocked             ,


-- ** asyncQueuePushUnlocked
    asyncQueuePushUnlocked                  ,


-- ** asyncQueueRefUnlocked
    asyncQueueRefUnlocked                   ,


-- ** asyncQueueRemove
    asyncQueueRemove                        ,


-- ** asyncQueueRemoveUnlocked
    asyncQueueRemoveUnlocked                ,


-- ** asyncQueueUnlock
    asyncQueueUnlock                        ,


-- ** asyncQueueUnref
    asyncQueueUnref                         ,


-- ** asyncQueueUnrefAndUnlock
    asyncQueueUnrefAndUnlock                ,




    ) 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 AsyncQueue = AsyncQueue (ForeignPtr AsyncQueue)
noAsyncQueue :: Maybe AsyncQueue
noAsyncQueue = Nothing

-- method AsyncQueue::length
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_length" g_async_queue_length :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO Int32


asyncQueueLength ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m Int32
asyncQueueLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_async_queue_length _obj'
    touchManagedPtr _obj
    return result

-- method AsyncQueue::length_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_length_unlocked" g_async_queue_length_unlocked :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO Int32


asyncQueueLengthUnlocked ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m Int32
asyncQueueLengthUnlocked _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_async_queue_length_unlocked _obj'
    touchManagedPtr _obj
    return result

-- method AsyncQueue::lock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_lock" g_async_queue_lock :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO ()


asyncQueueLock ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m ()
asyncQueueLock _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_lock _obj'
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::push
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_push" g_async_queue_push :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- data : TBasicType TVoid
    IO ()


asyncQueuePush ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- data
    m ()
asyncQueuePush _obj data_ = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_push _obj' data_
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::push_front
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_push_front" g_async_queue_push_front :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- item : TBasicType TVoid
    IO ()


asyncQueuePushFront ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- item
    m ()
asyncQueuePushFront _obj item = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_push_front _obj' item
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::push_front_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_push_front_unlocked" g_async_queue_push_front_unlocked :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- item : TBasicType TVoid
    IO ()


asyncQueuePushFrontUnlocked ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- item
    m ()
asyncQueuePushFrontUnlocked _obj item = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_push_front_unlocked _obj' item
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::push_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_push_unlocked" g_async_queue_push_unlocked :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- data : TBasicType TVoid
    IO ()


asyncQueuePushUnlocked ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- data
    m ()
asyncQueuePushUnlocked _obj data_ = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_push_unlocked _obj' data_
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::ref_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_ref_unlocked" g_async_queue_ref_unlocked :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO ()

{-# DEPRECATED asyncQueueRefUnlocked ["(Since version 2.8)","Reference counting is done atomically.","so g_async_queue_ref() can be used regardless of the @queue's","lock."]#-}
asyncQueueRefUnlocked ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m ()
asyncQueueRefUnlocked _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_ref_unlocked _obj'
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_remove" g_async_queue_remove :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- item : TBasicType TVoid
    IO CInt


asyncQueueRemove ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- item
    m Bool
asyncQueueRemove _obj item = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_async_queue_remove _obj' item
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method AsyncQueue::remove_unlocked
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "item", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_remove_unlocked" g_async_queue_remove_unlocked :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    Ptr () ->                               -- item : TBasicType TVoid
    IO CInt


asyncQueueRemoveUnlocked ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    Ptr () ->                               -- item
    m Bool
asyncQueueRemoveUnlocked _obj item = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_async_queue_remove_unlocked _obj' item
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method AsyncQueue::unlock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_unlock" g_async_queue_unlock :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO ()


asyncQueueUnlock ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m ()
asyncQueueUnlock _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_unlock _obj'
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_unref" g_async_queue_unref :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO ()


asyncQueueUnref ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m ()
asyncQueueUnref _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_unref _obj'
    touchManagedPtr _obj
    return ()

-- method AsyncQueue::unref_and_unlock
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "AsyncQueue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_async_queue_unref_and_unlock" g_async_queue_unref_and_unlock :: 
    Ptr AsyncQueue ->                       -- _obj : TInterface "GLib" "AsyncQueue"
    IO ()

{-# DEPRECATED asyncQueueUnrefAndUnlock ["(Since version 2.8)","Reference counting is done atomically.","so g_async_queue_unref() can be used regardless of the @queue's","lock."]#-}
asyncQueueUnrefAndUnlock ::
    (MonadIO m) =>
    AsyncQueue ->                           -- _obj
    m ()
asyncQueueUnrefAndUnlock _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_async_queue_unref_and_unlock _obj'
    touchManagedPtr _obj
    return ()