4 * Bounded, blocking queue for inter-thread communication. Note: consumer side is
7 * Copyright (c) 2012 Nathan Keynes.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #ifndef lxdream_tqueue_H
21 #define lxdream_tqueue_H 1
23 #include "glib/gtypes.h"
30 * Callback function to be invoked on the consumer side.
32 typedef int (*tqueue_callback)(void *);
35 * Add a message to the UI queue and return immediately.
37 void tqueue_post_message( tqueue_callback callback, void *data );
40 * Add a message to the UI queue and wait for it to be handled.
41 * @return the result from the handler function.
43 int tqueue_send_message( tqueue_callback callback, void *data );
45 /************** Consumer thread **************/
48 * Process all messages in the queue, if any.
50 void tqueue_process_all();
53 * Process the first message in the queue. If no messages are on the
54 * queue, waits for the next one to be queued and then processes it.
56 void tqueue_process_wait();
62 #endif /* !lxdream_tqueue_H */
.