Search
lxdream.org :: lxdream/src/tqueue.h :: diff
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
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/tqueue.h Fri Mar 02 23:49:10 2012 +1000
1.3 @@ -0,0 +1,62 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Bounded, blocking queue for inter-thread communication. Note: consumer side is
1.8 + * re-entrant.
1.9 + *
1.10 + * Copyright (c) 2012 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 +#ifndef lxdream_tqueue_H
1.24 +#define lxdream_tqueue_H 1
1.25 +
1.26 +#include "glib/gtypes.h"
1.27 +
1.28 +#ifdef __cplusplus
1.29 +extern "C" {
1.30 +#endif
1.31 +
1.32 +/**
1.33 + * Callback function to be invoked on the consumer side.
1.34 + */
1.35 +typedef int (*tqueue_callback)(void *);
1.36 +
1.37 +/**
1.38 + * Add a message to the UI queue and return immediately.
1.39 + */
1.40 +void tqueue_post_message( tqueue_callback callback, void *data );
1.41 +
1.42 +/**
1.43 + * Add a message to the UI queue and wait for it to be handled.
1.44 + * @return the result from the handler function.
1.45 + */
1.46 +int tqueue_send_message( tqueue_callback callback, void *data );
1.47 +
1.48 +/************** Consumer thread **************/
1.49 +
1.50 +/**
1.51 + * Process all messages in the queue, if any.
1.52 + */
1.53 +void tqueue_process_all();
1.54 +
1.55 +/**
1.56 + * Process the first message in the queue. If no messages are on the
1.57 + * queue, waits for the next one to be queued and then processes it.
1.58 + */
1.59 +void tqueue_process_wait();
1.60 +
1.61 +#ifdef __cplusplus
1.62 +}
1.63 +#endif
1.64 +
1.65 +#endif /* !lxdream_tqueue_H */
.