Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
The GAsyncQueue struct is an opaque data structure which represents an asynchronous queue. It should only be accessed through the g_async_queue_* functions.
- newtype AsyncQueue = AsyncQueue (ManagedPtr AsyncQueue)
- noAsyncQueue :: Maybe AsyncQueue
- data AsyncQueueLengthMethodInfo
- asyncQueueLength :: (HasCallStack, MonadIO m) => AsyncQueue -> m Int32
- data AsyncQueueLengthUnlockedMethodInfo
- asyncQueueLengthUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> m Int32
- data AsyncQueueLockMethodInfo
- asyncQueueLock :: (HasCallStack, MonadIO m) => AsyncQueue -> m ()
- data AsyncQueuePopMethodInfo
- asyncQueuePop :: (HasCallStack, MonadIO m) => AsyncQueue -> m (Ptr ())
- data AsyncQueuePopUnlockedMethodInfo
- asyncQueuePopUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> m (Ptr ())
- data AsyncQueuePushMethodInfo
- asyncQueuePush :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m ()
- data AsyncQueuePushFrontMethodInfo
- asyncQueuePushFront :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m ()
- data AsyncQueuePushFrontUnlockedMethodInfo
- asyncQueuePushFrontUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m ()
- data AsyncQueuePushUnlockedMethodInfo
- asyncQueuePushUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m ()
- data AsyncQueueRefUnlockedMethodInfo
- asyncQueueRefUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> m ()
- data AsyncQueueRemoveMethodInfo
- asyncQueueRemove :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m Bool
- data AsyncQueueRemoveUnlockedMethodInfo
- asyncQueueRemoveUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> Ptr () -> m Bool
- data AsyncQueueTimedPopMethodInfo
- asyncQueueTimedPop :: (HasCallStack, MonadIO m) => AsyncQueue -> TimeVal -> m (Ptr ())
- data AsyncQueueTimedPopUnlockedMethodInfo
- asyncQueueTimedPopUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> TimeVal -> m (Ptr ())
- data AsyncQueueTimeoutPopMethodInfo
- asyncQueueTimeoutPop :: (HasCallStack, MonadIO m) => AsyncQueue -> Word64 -> m (Ptr ())
- data AsyncQueueTimeoutPopUnlockedMethodInfo
- asyncQueueTimeoutPopUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> Word64 -> m (Ptr ())
- data AsyncQueueTryPopMethodInfo
- asyncQueueTryPop :: (HasCallStack, MonadIO m) => AsyncQueue -> m (Ptr ())
- data AsyncQueueTryPopUnlockedMethodInfo
- asyncQueueTryPopUnlocked :: (HasCallStack, MonadIO m) => AsyncQueue -> m (Ptr ())
- data AsyncQueueUnlockMethodInfo
- asyncQueueUnlock :: (HasCallStack, MonadIO m) => AsyncQueue -> m ()
- data AsyncQueueUnrefMethodInfo
- asyncQueueUnref :: (HasCallStack, MonadIO m) => AsyncQueue -> m ()
- data AsyncQueueUnrefAndUnlockMethodInfo
- asyncQueueUnrefAndUnlock :: (HasCallStack, MonadIO m) => AsyncQueue -> m ()
Exported types
newtype AsyncQueue Source #
Methods
length
data AsyncQueueLengthMethodInfo Source #
((~) * signature (m Int32), MonadIO m) => MethodInfo * AsyncQueueLengthMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> m Int32 | Returns: the length of the |
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
data AsyncQueueLengthUnlockedMethodInfo Source #
((~) * signature (m Int32), MonadIO m) => MethodInfo * AsyncQueueLengthUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueLengthUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> m Int32 | Returns: the length of the |
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 Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueLockMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> 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 Source #
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueuePopMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> 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
data AsyncQueuePopUnlockedMethodInfo Source #
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueuePopUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueuePopUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> 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 Source #
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> m () |
Pushes the data
into the queue
. data
must not be Nothing
.
pushFront
data AsyncQueuePushFrontMethodInfo Source #
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushFrontMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> 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
data AsyncQueuePushFrontUnlockedMethodInfo Source #
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushFrontUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueuePushFrontUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> 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
data AsyncQueuePushUnlockedMethodInfo Source #
((~) * signature (Ptr () -> m ()), MonadIO m) => MethodInfo * AsyncQueuePushUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueuePushUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> m () |
Pushes the data
into the queue
. data
must not be Nothing
.
This function must be called while holding the queue
's lock.
refUnlocked
data AsyncQueueRefUnlockedMethodInfo Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueRefUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueRefUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> 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
data AsyncQueueRemoveMethodInfo Source #
((~) * signature (Ptr () -> m Bool), MonadIO m) => MethodInfo * AsyncQueueRemoveMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> m Bool | Returns: |
Remove an item from the queue.
Since: 2.46
removeUnlocked
data AsyncQueueRemoveUnlockedMethodInfo Source #
((~) * signature (Ptr () -> m Bool), MonadIO m) => MethodInfo * AsyncQueueRemoveUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueRemoveUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Ptr () |
|
-> m Bool | Returns: |
Remove an item from the queue.
This function must be called while holding the queue
's lock.
Since: 2.46
timedPop
data AsyncQueueTimedPopMethodInfo Source #
((~) * signature (TimeVal -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimedPopMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> TimeVal |
|
-> m (Ptr ()) | Returns: data from the queue or |
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
data AsyncQueueTimedPopUnlockedMethodInfo Source #
((~) * signature (TimeVal -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimedPopUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueTimedPopUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> TimeVal |
|
-> m (Ptr ()) | Returns: data from the queue or |
Deprecated: use asyncQueueTimeoutPopUnlocked
.
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
data AsyncQueueTimeoutPopMethodInfo Source #
((~) * signature (Word64 -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimeoutPopMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Word64 |
|
-> m (Ptr ()) | Returns: data from the queue or |
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
data AsyncQueueTimeoutPopUnlockedMethodInfo Source #
((~) * signature (Word64 -> m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTimeoutPopUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueTimeoutPopUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> Word64 |
|
-> m (Ptr ()) | Returns: data from the queue or |
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
data AsyncQueueTryPopMethodInfo Source #
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTryPopMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> m (Ptr ()) | Returns: data from the queue or |
Tries to pop data from the queue
. If no data is available,
Nothing
is returned.
tryPopUnlocked
data AsyncQueueTryPopUnlockedMethodInfo Source #
((~) * signature (m (Ptr ())), MonadIO m) => MethodInfo * AsyncQueueTryPopUnlockedMethodInfo AsyncQueue signature Source # | |
asyncQueueTryPopUnlocked Source #
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> m (Ptr ()) | Returns: data from the queue or |
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
data AsyncQueueUnlockMethodInfo Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnlockMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> AsyncQueue |
|
-> m () |
Releases the queue's lock.
Calling this function when you have not acquired
the with asyncQueueLock
leads to undefined
behaviour.
unref
data AsyncQueueUnrefMethodInfo Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnrefMethodInfo AsyncQueue signature Source # | |
:: (HasCallStack, MonadIO m) | |
=> 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
data AsyncQueueUnrefAndUnlockMethodInfo Source #
((~) * signature (m ()), MonadIO m) => MethodInfo * AsyncQueueUnrefAndUnlockMethodInfo AsyncQueue signature Source # | |
asyncQueueUnrefAndUnlock Source #
:: (HasCallStack, MonadIO m) | |
=> 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.