1
{$ifndef __G_ASYNCQUEUE_H__}
2
{$define __G_ASYNCQUEUE_H__}
4
// {$include gthread.inc}
6
{* Asyncronous Queues, can be used to communicate between threads
10
PGAsyncQueue = pointer;
11
{* Get a new GAsyncQueue with the ref_count 1 *}
13
function g_async_queue_new:PGAsyncQueue;cdecl;external gliblib name 'g_async_queue_new';
15
{* Lock and unlock an GAsyncQueue, all functions lock the queue for
16
* themselves, but in certain cirumstances you want to hold the lock longer,
17
* thus you lock the queue, call the *_unlocked functions and unlock it again
19
procedure g_async_queue_lock(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_lock';
20
procedure g_async_queue_unlock(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_unlock';
23
{* Ref and unref the GAsyncQueue. g_async_queue_unref_unlocked makes
24
* no sense, as after the unreffing the Queue might be gone and can't
25
* be unlocked. So you have a function to call, if you don't hold the
26
* lock (g_async_queue_unref) and one to call, when you already hold
27
* the lock (g_async_queue_unref_and_unlock). After that however, you
28
* don't hold the lock anymore and the Queue might in fact be
29
* destroyed, if you unrefed to zero *}
31
procedure g_async_queue_ref(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_ref';
32
procedure g_async_queue_ref_unlocked(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_ref_unlocked';
33
procedure g_async_queue_unref(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_unref';
34
procedure g_async_queue_unref_and_unlock(queue:PGAsyncQueue);cdecl;external gliblib name 'g_async_queue_unref_and_unlock';
36
{* Push data into the async queue. Must not be NULL *}
37
procedure g_async_queue_push(queue:PGAsyncQueue; data:gpointer);cdecl;external gliblib name 'g_async_queue_push';
38
procedure g_async_queue_push_unlocked(queue:PGAsyncQueue; data:gpointer);cdecl;external gliblib name 'g_async_queue_push_unlocked';
40
{* Pop data from the async queue, when no data is there, the thread is blocked
41
* until data arrives *}
42
function g_async_queue_pop(queue:PGAsyncQueue):gpointer;cdecl;external gliblib name 'g_async_queue_pop';
43
function g_async_queue_pop_unlocked(queue:PGAsyncQueue):gpointer;cdecl;external gliblib name 'g_async_queue_pop_unlocked';
45
{* Try to pop data, NULL is returned in case of empty queue *}
46
function g_async_queue_try_pop(queue:PGAsyncQueue):gpointer;cdecl;external gliblib name 'g_async_queue_try_pop';
47
function g_async_queue_try_pop_unlocked(queue:PGAsyncQueue):gpointer;cdecl;external gliblib name 'g_async_queue_try_pop_unlocked';
49
{* Wait for data until at maximum until end_time is reached, NULL is returned
50
* in case of empty queue*}
51
function g_async_queue_timed_pop(queue:PGAsyncQueue; end_time:PGTimeVal):gpointer;cdecl;external gliblib name 'g_async_queue_timed_pop';
52
function g_async_queue_timed_pop_unlocked(queue:PGAsyncQueue; end_time:PGTimeVal):gpointer;cdecl;external gliblib name 'g_async_queue_timed_pop_unlocked';
55
{* Return the length of the queue, negative values mean, that threads
56
* are waiting, positve values mean, that there are entries in the
57
* queue. Actually this function returns the length of the queue minus
58
* the number of waiting threads, g_async_queue_length == 0 could also
59
* mean 'n' entries in the queue and 'n' thread waiting, such can
60
* happen due to locking of the queue or due to scheduling. *}
62
function g_async_queue_length(queue:PGAsyncQueue):gint;cdecl;external gliblib name 'g_async_queue_length';
63
function g_async_queue_length_unlocked(queue:PGAsyncQueue):gint;cdecl;external gliblib name 'g_async_queue_length_unlocked';