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
file annotate diff log raw
nkeynes@1245
     1
/**
nkeynes@1245
     2
 * $Id$
nkeynes@1245
     3
 *
nkeynes@1245
     4
 * Bounded, blocking queue for inter-thread communication. Note: consumer side is
nkeynes@1245
     5
 * re-entrant.
nkeynes@1245
     6
 *
nkeynes@1245
     7
 * Copyright (c) 2012 Nathan Keynes.
nkeynes@1245
     8
 *
nkeynes@1245
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@1245
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@1245
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1245
    12
 * (at your option) any later version.
nkeynes@1245
    13
 *
nkeynes@1245
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@1245
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1245
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1245
    17
 * GNU General Public License for more details.
nkeynes@1245
    18
 */
nkeynes@1245
    19
nkeynes@1245
    20
#ifndef lxdream_tqueue_H
nkeynes@1245
    21
#define lxdream_tqueue_H 1
nkeynes@1245
    22
nkeynes@1245
    23
#include "glib/gtypes.h"
nkeynes@1245
    24
nkeynes@1245
    25
#ifdef __cplusplus
nkeynes@1245
    26
extern "C" {
nkeynes@1245
    27
#endif
nkeynes@1245
    28
nkeynes@1245
    29
/**
nkeynes@1245
    30
 * Callback function to be invoked on the consumer side.
nkeynes@1245
    31
 */
nkeynes@1245
    32
typedef int (*tqueue_callback)(void *);
nkeynes@1245
    33
nkeynes@1245
    34
/**
nkeynes@1245
    35
 * Add a message to the UI queue and return immediately.
nkeynes@1245
    36
 */
nkeynes@1245
    37
void tqueue_post_message( tqueue_callback callback, void *data );
nkeynes@1245
    38
nkeynes@1245
    39
/**
nkeynes@1245
    40
 * Add a message to the UI queue and wait for it to be handled.
nkeynes@1245
    41
 * @return the result from the handler function.
nkeynes@1245
    42
 */
nkeynes@1245
    43
int tqueue_send_message( tqueue_callback callback, void *data );
nkeynes@1245
    44
nkeynes@1245
    45
/************** Consumer thread **************/
nkeynes@1245
    46
nkeynes@1245
    47
/**
nkeynes@1245
    48
 * Process all messages in the queue, if any.
nkeynes@1245
    49
 */
nkeynes@1245
    50
void tqueue_process_all();
nkeynes@1245
    51
nkeynes@1245
    52
/**
nkeynes@1245
    53
 * Process the first message in the queue. If no messages are on the
nkeynes@1245
    54
 * queue, waits for the next one to be queued and then processes it.
nkeynes@1245
    55
 */
nkeynes@1245
    56
void tqueue_process_wait();
nkeynes@1245
    57
nkeynes@1245
    58
#ifdef __cplusplus
nkeynes@1245
    59
}
nkeynes@1245
    60
#endif
nkeynes@1245
    61
nkeynes@1245
    62
#endif /* !lxdream_tqueue_H */
.