mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
e942fe6528
The queues in the curses resources struct have been cleaned up and the threading support code (including for the queues (pipes, really)) has been moved to its own file. The input test app currently just prints the devices and the events as they come in, but demonstrates the new input system working in a separate thread (though it is currently in with the curses thread).
39 lines
1,011 B
C
39 lines
1,011 B
C
#ifndef __qwaq_threading_h
|
|
#define __qwaq_threading_h
|
|
|
|
#ifndef __QFCC__
|
|
|
|
#include "QF/dstring.h"
|
|
#include "QF/ringbuffer.h"
|
|
|
|
#define QUEUE_SIZE 16
|
|
#define STRING_ID_QUEUE_SIZE 8
|
|
#define COMMAND_QUEUE_SIZE 1280
|
|
|
|
typedef struct rwcond_s {
|
|
pthread_cond_t rcond;
|
|
pthread_cond_t wcond;
|
|
pthread_mutex_t mut;
|
|
} rwcond_t;
|
|
|
|
typedef struct qwaq_pipe_s {
|
|
rwcond_t pipe_cond;
|
|
RING_BUFFER (int, COMMAND_QUEUE_SIZE) pipe;
|
|
|
|
rwcond_t string_id_cond;
|
|
RING_BUFFER (int, STRING_ID_QUEUE_SIZE + 1) string_ids;
|
|
dstring_t strings[STRING_ID_QUEUE_SIZE];
|
|
} qwaq_pipe_t;
|
|
|
|
void qwaq_pipe_submit (qwaq_pipe_t *pipe, const int *data, unsigned len);
|
|
void qwaq_pipe_receive (qwaq_pipe_t *pipe, int *data, int id, unsigned len);
|
|
int qwaq_pipe_acquire_string (qwaq_pipe_t *pipe);
|
|
void qwaq_pipe_release_string (qwaq_pipe_t *pipe, int string_id);
|
|
|
|
void qwaq_init_pipe (qwaq_pipe_t *pipe);
|
|
void qwaq_init_timeout (struct timespec *timeout, int64_t time);
|
|
void qwaq_init_cond (rwcond_t *cond);
|
|
|
|
#endif
|
|
|
|
#endif//__qwaq_threading_h
|