2
abstraction for threads
3
Copyright (C) 2000 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
14
#ifndef __ABS_THREAD_H
15
#define __ABS_THREAD_H
23
This passed alle pthread_xxx calls to this interface, thus
24
it can be easier replaced with other thread "layers"
26
All posix pthread calls are conveterd to abs_thread.
39
#define _ABS_BUSY EBUSY
42
// definitions for direct pthread support
45
typedef pthread_mutex_t abs_thread_mutex_t;
46
typedef pthread_cond_t abs_thread_cond_t;
47
typedef pthread_t abs_thread_t;
51
#define abs_thread_cond_init(cond) pthread_cond_init(cond,NULL)
52
#define abs_thread_cond_destroy(cond) pthread_cond_destroy(cond)
53
#define abs_thread_cond_signal(cond) pthread_cond_signal(cond)
54
#define abs_thread_cond_wait(cond,mutex) pthread_cond_wait(cond,mutex)
56
// CREATE / JOIN THREAD
58
#define abs_thread_create(thread,func,arg) pthread_create(thread,NULL,func,arg)
59
#define abs_thread_join(th,thread_return) pthread_join(th,thread_return)
63
#define abs_thread_mutex_lock(mutex) pthread_mutex_lock(mutex)
64
#define abs_thread_mutex_unlock(mutex) pthread_mutex_unlock(mutex)
65
#define abs_thread_mutex_init(mutex) pthread_mutex_init(mutex,NULL)
66
#define abs_thread_mutex_destroy(mutex) pthread_mutex_destroy(mutex)
74
// SDL SUPPORT DISABLED
77
#include <SDL_thread.h>
78
#include <SDL_mutex.h>
80
#include <SDL/SDL_thread.h>
81
#include <SDL/SDL_mutex.h>
85
typedef SDL_mutex* abs_thread_mutex_t;
86
typedef SDL_cond* abs_thread_cond_t;
87
typedef SDL_Thread* abs_thread_t;
90
// note we have _no_ cond attribut (not needed)
91
int abs_thread_cond_init(abs_thread_cond_t* cond);
92
int abs_thread_cond_destroy(abs_thread_cond_t *cond);
94
int abs_thread_cond_signal(abs_thread_cond_t* cond);
96
int abs_thread_cond_wait(abs_thread_cond_t* cond,
97
abs_thread_mutex_t *mutex);
98
// CREATE / JOIN THREAD
99
// Note: we have thread attribute
100
int abs_thread_create(abs_thread_t* thread,
101
void * (*start_routine)(void *), void * arg);
103
int abs_thread_join(abs_thread_t th,
104
void **thread_return);
109
int abs_thread_mutex_lock(abs_thread_mutex_t *mutex);
110
int abs_thread_mutex_trylock(abs_thread_mutex_t *mutex);
111
int abs_thread_mutex_unlock(abs_thread_mutex_t *mutex);
113
int abs_thread_mutex_init(abs_thread_mutex_t *mutex);
115
int abs_thread_mutex_destroy(abs_thread_mutex_t *mutex);