Search
lxdream.org :: lxdream/src/tqueue.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/tqueue.h
changeset 1245:01e0020adf88
next1296:30ecee61f811
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
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/gtypes.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 */
.