FreeWRL / FreeX3D 4.3.0
threads.h
1/*
2
3 FreeWRL support library.
4 Threads & process (fork).
5
6*/
7
8/****************************************************************************
9 This file is part of the FreeWRL/FreeX3D Distribution.
10
11 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12
13 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Lesser Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25****************************************************************************/
26
27
28#ifndef __LIBFREEWRL_THREADS_H__
29#define __LIBFREEWRL_THREADS_H__
30
31/* for some reason, OSX now needs this one, too (July 2010) */
32/*
33OLD_IPHONE_AQUA
34OLD_IPHONE_AQUA #ifdef AQUA
35OLD_IPHONE_AQUA #include <system_threads.h>
36OLD_IPHONE_AQUA #endif
37*/
38
39#ifdef _MSC_VER
40#include <system_threads.h>
41#endif
42
43#ifdef _ANDROID
44#include <system_threads.h>
45#endif
46
47
48
49int freewrlSystem(const char *string);
50
62#define FREEWRL_MAX_THREADS 5
63
64#define FREEWRL_THREAD_MAIN 1
65#define FREEWRL_THREAD_DISPLAY 2
66#define FREEWRL_THREAD_PARSER 3
67#define FREEWRL_THREAD_TEXTURE 4
68
69extern pthread_t mainThread; /* main (default) thread */
70extern pthread_t DispThrd; /* display thread */
71extern pthread_t PCthread; /* parser thread */
72extern pthread_t loadThread; /* texture thread */
73
77/* DISPLAY THREAD */
78#if !defined(FRONTEND_HANDLES_DISPLAY_THREAD)
79void _displayThread(void *globalcontext);
80#endif /* FRONTEND_HANDLES_DISPLAY_THREAD */
81
82/* PARSER THREAD */
83void _inputParseThread (void *globalcontext);
84
85/* TEXTURE THREAD */
86void _textureThread(void *globalcontext);
87
88int fw_thread_id();
89#ifdef FREEWRL_THREAD_COLORIZED
90int fw_thread_color(int thread_id);
91#endif
92/* void fw_thread_dump(); */
93
94#define ENTER_THREAD(_str) trace_enter_thread(_str)
95void trace_enter_thread(const char *str);
96
97extern pthread_mutex_t mutex_resource_tree;
98extern pthread_mutex_t mutex_resource_list;
99extern pthread_mutex_t mutex_texture_list;
100extern pthread_cond_t texture_list_condition;
101extern pthread_cond_t resource_list_condition;
102
103
104#endif /* __LIBFREEWRL_THREADS_H__ */