~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/util/abstract/abs_thread.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  abstraction for threads
 
3
  Copyright (C) 2000 Martin Vogt
 
4
 
 
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.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
#ifndef __ABS_THREAD_H
 
15
#define __ABS_THREAD_H
 
16
 
 
17
 
 
18
#ifdef HAVE_CONFIG_H
 
19
#include "config.h"
 
20
#endif
 
21
 
 
22
/**
 
23
   This passed alle pthread_xxx calls to this interface, thus
 
24
   it can be easier replaced with other thread "layers"
 
25
 
 
26
   All posix pthread calls are conveterd to abs_thread.
 
27
*/
 
28
 
 
29
extern "C" {
 
30
#include <stdio.h>
 
31
#include <stdlib.h>
 
32
#include <errno.h>
 
33
#include <string.h>
 
34
}
 
35
 
 
36
#include <iostream.h>
 
37
 
 
38
 
 
39
#define _ABS_BUSY EBUSY
 
40
 
 
41
#ifndef SDL_WRAPPER
 
42
// definitions for direct pthread support
 
43
#include <pthread.h>
 
44
 
 
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;
 
48
 
 
49
 
 
50
 
 
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)
 
55
 
 
56
// CREATE / JOIN THREAD
 
57
 
 
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)
 
60
 
 
61
// MUTEX FUNCTIONS
 
62
 
 
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)
 
67
 
 
68
#endif
 
69
// not SDL_WRAPPER
 
70
 
 
71
#ifdef SDL_WRAPPER
 
72
 
 
73
 
 
74
// SDL SUPPORT DISABLED 
 
75
 
 
76
#if defined WIN32
 
77
  #include <SDL_thread.h>
 
78
  #include <SDL_mutex.h>
 
79
#else
 
80
  #include <SDL/SDL_thread.h>
 
81
  #include <SDL/SDL_mutex.h>
 
82
#endif
 
83
 
 
84
 
 
85
typedef SDL_mutex* abs_thread_mutex_t;
 
86
typedef SDL_cond*  abs_thread_cond_t;
 
87
typedef SDL_Thread* abs_thread_t;
 
88
 
 
89
// SIGNAL FUNCTIONS
 
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);
 
93
 
 
94
int abs_thread_cond_signal(abs_thread_cond_t* cond);
 
95
 
 
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);
 
102
 
 
103
int abs_thread_join(abs_thread_t th, 
 
104
                    void **thread_return);
 
105
 
 
106
 
 
107
// MUTEX FUNCTIONS
 
108
 
 
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);
 
112
// not attribute!
 
113
int abs_thread_mutex_init(abs_thread_mutex_t   *mutex);
 
114
 
 
115
int abs_thread_mutex_destroy(abs_thread_mutex_t *mutex);
 
116
 
 
117
 
 
118
 
 
119
#endif
 
120
//SDL_WRAPPER
 
121
 
 
122
 
 
123
 
 
124
#endif
 
125
 
 
126