Search
lxdream.org :: lxdream/src/tqueue.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/tqueue.h
changeset 1296:30ecee61f811
prev1245:01e0020adf88
author nkeynes
date Sat Jan 26 14:00:48 2013 +1000 (9 years ago)
permissions -rw-r--r--
last change Change glib includes to #include <glib.h> rather than the individual
headers, as recent glib versions are breaking on this
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Bounded, blocking queue for inter-thread communication. Note: consumer side is
     5  * re-entrant.
     6  *
     7  * Copyright (c) 2012 Nathan Keynes.
     8  *
     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.
    13  *
    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.
    18  */
    20 #ifndef lxdream_tqueue_H
    21 #define lxdream_tqueue_H 1
    23 #include <glib.h>
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 /**
    30  * Callback function to be invoked on the consumer side.
    31  */
    32 typedef int (*tqueue_callback)(void *);
    34 /**
    35  * Add a message to the UI queue and return immediately.
    36  */
    37 void tqueue_post_message( tqueue_callback callback, void *data );
    39 /**
    40  * Add a message to the UI queue and wait for it to be handled.
    41  * @return the result from the handler function.
    42  */
    43 int tqueue_send_message( tqueue_callback callback, void *data );
    45 /************** Consumer thread **************/
    47 /**
    48  * Process all messages in the queue, if any.
    49  */
    50 void tqueue_process_all();
    52 /**
    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.
    55  */
    56 void tqueue_process_wait();
    58 #ifdef __cplusplus
    59 }
    60 #endif
    62 #endif /* !lxdream_tqueue_H */
.