gi-glib-2.0.12: GLib bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.GLib.Structs.AsyncQueue

Contents

Description

The GAsyncQueue struct is an opaque data structure which represents an asynchronous queue. It should only be accessed through the g_async_queue_* functions.

Synopsis

Exported types

newtype AsyncQueue #

Instances

WrappedPtr AsyncQueue # 
((~) * info (ResolveAsyncQueueMethod t AsyncQueue), MethodInfo * info AsyncQueue p) => IsLabel t (AsyncQueue -> p) # 

Methods

fromLabel :: Proxy# Symbol t -> AsyncQueue -> p #

((~) * info (ResolveAsyncQueueMethod t AsyncQueue), MethodInfo * info AsyncQueue p) => IsLabelProxy t (AsyncQueue -> p) # 

Methods

fromLabelProxy :: Proxy Symbol t -> AsyncQueue -> p #

HasAttributeList * AsyncQueue # 
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnrefAndUnlockMethodInfo AsyncQueue signature # 
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnrefMethodInfo AsyncQueue signature # 
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnlockMethodInfo AsyncQueue signature # 
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTryPopUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTryPopMethodInfo AsyncQueue signature # 
((~) * signature (Word64 -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimeoutPopUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (Word64 -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimeoutPopMethodInfo AsyncQueue signature # 
((~) * signature (TimeVal -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimedPopUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (TimeVal -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimedPopMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m Bool), MonadIO m) => MethodInfo * AsyncQueueRemoveUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m Bool), MonadIO m) => MethodInfo * AsyncQueueRemoveMethodInfo AsyncQueue signature # 
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueRefUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushFrontUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushFrontMethodInfo AsyncQueue signature # 
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushMethodInfo AsyncQueue signature # 
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueuePopUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueuePopMethodInfo AsyncQueue signature # 
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueLockMethodInfo AsyncQueue signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * AsyncQueueLengthUnlockedMethodInfo AsyncQueue signature # 
((~) * signature (m Int32), MonadIO m) => MethodInfo * AsyncQueueLengthMethodInfo AsyncQueue signature # 
type AttributeList AsyncQueue # 

Methods

length

asyncQueueLength #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue.

-> m Int32

Returns: the length of the queue

Returns the length of the queue.

Actually this function returns the number of data items in the queue minus the number of waiting threads, so a negative value means waiting threads, and a positive value means available entries in the queue. A return value of 0 could mean n entries in the queue and n threads waiting. This can happen due to locking of the queue or due to scheduling.

lengthUnlocked

asyncQueueLengthUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m Int32

Returns: the length of the queue.

Returns the length of the queue.

Actually this function returns the number of data items in the queue minus the number of waiting threads, so a negative value means waiting threads, and a positive value means available entries in the queue. A return value of 0 could mean n entries in the queue and n threads waiting. This can happen due to locking of the queue or due to scheduling.

This function must be called while holding the queue's lock.

lock

data AsyncQueueLockMethodInfo #

Instances

((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueLockMethodInfo AsyncQueue signature # 

asyncQueueLock #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m () 

Acquires the queue's lock. If another thread is already holding the lock, this call will block until the lock becomes available.

Call asyncQueueUnlock to drop the lock again.

While holding the lock, you can only call the g_async_queue_*_unlocked() functions on queue. Otherwise, deadlock may occur.

pop

data AsyncQueuePopMethodInfo #

Instances

((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueuePopMethodInfo AsyncQueue signature # 

asyncQueuePop #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m (Ptr ())

Returns: data from the queue

Pops data from the queue. If queue is empty, this function blocks until data becomes available.

popUnlocked

asyncQueuePopUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m (Ptr ())

Returns: data from the queue.

Pops data from the queue. If queue is empty, this function blocks until data becomes available.

This function must be called while holding the queue's lock.

push

data AsyncQueuePushMethodInfo #

Instances

((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushMethodInfo AsyncQueue signature # 

asyncQueuePush #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

data: data to push into the queue

-> m () 

Pushes the data into the queue. data must not be Nothing.

pushFront

asyncQueuePushFront #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

item: data to push into the queue

-> m () 

Pushes the item into the queue. item must not be Nothing. In contrast to asyncQueuePush, this function pushes the new item ahead of the items already in the queue, so that it will be the next one to be popped off the queue.

Since: 2.46

pushFrontUnlocked

asyncQueuePushFrontUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

item: data to push into the queue

-> m () 

Pushes the item into the queue. item must not be Nothing. In contrast to asyncQueuePushUnlocked, this function pushes the new item ahead of the items already in the queue, so that it will be the next one to be popped off the queue.

This function must be called while holding the queue's lock.

Since: 2.46

pushUnlocked

asyncQueuePushUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

data: data to push into the queue

-> m () 

Pushes the data into the queue. data must not be Nothing.

This function must be called while holding the queue's lock.

refUnlocked

asyncQueueRefUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m () 

Deprecated: (Since version 2.8)Reference counting is done atomically.so g_async_queue_ref() can be used regardless of the queue'slock.

Increases the reference count of the asynchronous queue by 1.

remove

asyncQueueRemove #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

item: the data to remove from the queue

-> m Bool

Returns: True if the item was removed

Remove an item from the queue.

Since: 2.46

removeUnlocked

asyncQueueRemoveUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Ptr ()

item: the data to remove from the queue

-> m Bool

Returns: True if the item was removed

Remove an item from the queue.

This function must be called while holding the queue's lock.

Since: 2.46

timedPop

asyncQueueTimedPop #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> TimeVal

endTime: a TimeVal, determining the final time

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is received before endTime.

Deprecated: use asyncQueueTimeoutPop.

Pops data from the queue. If the queue is empty, blocks until endTime or until data becomes available.

If no data is received before endTime, Nothing is returned.

To easily calculate endTime, a combination of getCurrentTime and timeValAdd can be used.

timedPopUnlocked

asyncQueueTimedPopUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> TimeVal

endTime: a TimeVal, determining the final time

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is received before endTime.

Pops data from the queue. If the queue is empty, blocks until endTime or until data becomes available.

If no data is received before endTime, Nothing is returned.

To easily calculate endTime, a combination of getCurrentTime and timeValAdd can be used.

This function must be called while holding the queue's lock.

timeoutPop

asyncQueueTimeoutPop #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Word64

timeout: the number of microseconds to wait

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is received before the timeout.

Pops data from the queue. If the queue is empty, blocks for timeout microseconds, or until data becomes available.

If no data is received before the timeout, Nothing is returned.

timeoutPopUnlocked

asyncQueueTimeoutPopUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> Word64

timeout: the number of microseconds to wait

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is received before the timeout.

Pops data from the queue. If the queue is empty, blocks for timeout microseconds, or until data becomes available.

If no data is received before the timeout, Nothing is returned.

This function must be called while holding the queue's lock.

tryPop

asyncQueueTryPop #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is available immediately.

Tries to pop data from the queue. If no data is available, Nothing is returned.

tryPopUnlocked

asyncQueueTryPopUnlocked #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m (Ptr ())

Returns: data from the queue or Nothing, when no data is available immediately.

Tries to pop data from the queue. If no data is available, Nothing is returned.

This function must be called while holding the queue's lock.

unlock

asyncQueueUnlock #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m () 

Releases the queue's lock.

Calling this function when you have not acquired the with asyncQueueLock leads to undefined behaviour.

unref

asyncQueueUnref #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue.

-> m () 

Decreases the reference count of the asynchronous queue by 1.

If the reference count went to 0, the queue will be destroyed and the memory allocated will be freed. So you are not allowed to use the queue afterwards, as it might have disappeared. You do not need to hold the lock to call this function.

unrefAndUnlock

asyncQueueUnrefAndUnlock #

Arguments

:: (HasCallStack, MonadIO m) 
=> AsyncQueue

queue: a AsyncQueue

-> m () 

Deprecated: (Since version 2.8)Reference counting is done atomically.so asyncQueueUnref can be used regardless of the queue'slock.

Decreases the reference count of the asynchronous queue by 1 and releases the lock. This function must be called while holding the queue's lock. If the reference count went to 0, the queue will be destroyed and the memory allocated will be freed.