src/thread.cpp
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
child 7053 e14047c5a8d0
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     1
/* $Id$ */
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     2
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
     3
/** @file thread.cpp */
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
     4
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     5
#include "stdafx.h"
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     6
#include "thread.h"
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     7
#include <stdlib.h>
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
     8
#include "helpers.hpp"
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
     9
6230
06c91ff0af27 (svn r8678) [PSP] -Add: added LIBS and CFLAGS needed to compile PSP
truelight
parents: 5860
diff changeset
    10
#if defined(__AMIGA__) || defined(__MORPHOS__) || defined(PSP) || defined(NO_THREADS)
4324
9c999cc382fa (svn r5978) -Add: allow a switch in Makefile.config to disable threads in OpenTTD (no matter what system you are on). Only useful for testing.
truelight
parents: 4300
diff changeset
    11
OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) { return NULL; }
9c999cc382fa (svn r5978) -Add: allow a switch in Makefile.config to disable threads in OpenTTD (no matter what system you are on). Only useful for testing.
truelight
parents: 4300
diff changeset
    12
void *OTTDJoinThread(OTTDThread *t) { return NULL; }
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6230
diff changeset
    13
void OTTDExitThread() { NOT_REACHED(); };
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    14
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    15
#elif defined(__OS2__)
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    16
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    17
#define INCL_DOS
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    18
#include <os2.h>
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    19
#include <process.h>
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    20
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    21
struct OTTDThread {
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    22
	TID thread;
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    23
	OTTDThreadFunc func;
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    24
	void* arg;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    25
	void* ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    26
};
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    27
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    28
static void Proxy(void* arg)
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    29
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    30
	OTTDThread* t = (OTTDThread*)arg;
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    31
	t->ret = t->func(t->arg);
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    32
}
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    33
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    34
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    35
{
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
    36
	OTTDThread* t = MallocT<OTTDThread>(1);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    37
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    38
	if (t == NULL) return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    39
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    40
	t->func = function;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    41
	t->arg  = arg;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    42
	t->thread = _beginthread(Proxy, NULL, 32768, t);
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
    43
	if (t->thread != (TID)-1) {
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    44
		return t;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    45
	} else {
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    46
		free(t);
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    47
		return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    48
	}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    49
}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    50
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    51
void* OTTDJoinThread(OTTDThread* t)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    52
{
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    53
	void* ret;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    54
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    55
	if (t == NULL) return NULL;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    56
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    57
	DosWaitThread(&t->thread, DCWW_WAIT);
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    58
	ret = t->ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    59
	free(t);
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    60
	return ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    61
}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    62
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6230
diff changeset
    63
void OTTDExitThread()
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
    64
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
    65
	_endthread();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
    66
}
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    67
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    68
#elif defined(UNIX)
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    69
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    70
#include <pthread.h>
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    71
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    72
struct OTTDThread {
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    73
	pthread_t thread;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    74
};
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    75
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    76
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    77
{
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
    78
	OTTDThread* t = MallocT<OTTDThread>(1);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    79
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    80
	if (t == NULL) return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    81
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    82
	if (pthread_create(&t->thread, NULL, function, arg) == 0) {
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    83
		return t;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    84
	} else {
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    85
		free(t);
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    86
		return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    87
	}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    88
}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    89
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
    90
void* OTTDJoinThread(OTTDThread* t)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    91
{
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    92
	void* ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    93
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    94
	if (t == NULL) return NULL;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    95
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    96
	pthread_join(t->thread, &ret);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    97
	free(t);
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
    98
	return ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
    99
}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   100
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6230
diff changeset
   101
void OTTDExitThread()
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   102
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   103
	pthread_exit(NULL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   104
}
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   105
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   106
#elif defined(WIN32)
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   107
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   108
#include <windows.h>
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   109
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
   110
struct OTTDThread {
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   111
	HANDLE thread;
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
   112
	OTTDThreadFunc func;
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   113
	void* arg;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   114
	void* ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   115
};
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   116
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   117
static DWORD WINAPI Proxy(LPVOID arg)
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   118
{
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   119
	OTTDThread* t = (OTTDThread*)arg;
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   120
	t->ret = t->func(t->arg);
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   121
	return 0;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   122
}
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   123
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
   124
OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   125
{
5860
7fdc9b423ba1 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5838
diff changeset
   126
	OTTDThread* t = MallocT<OTTDThread>(1);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   127
	DWORD dwThreadId;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   128
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   129
	if (t == NULL) return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   130
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   131
	t->func = function;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   132
	t->arg  = arg;
2287
2e556bae5fbb (svn r2811) Fix typos in r2810
tron
parents: 2286
diff changeset
   133
	t->thread = CreateThread(NULL, 0, Proxy, t, 0, &dwThreadId);
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   134
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   135
	if (t->thread != NULL) {
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   136
		return t;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   137
	} else {
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   138
		free(t);
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   139
		return NULL;
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   140
	}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   141
}
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   142
4298
3417f80deca1 (svn r5943) -Merge TGP (part r5725): -Codechange: renamed Thread to OTTDThread, as Windows
truelight
parents: 2290
diff changeset
   143
void* OTTDJoinThread(OTTDThread* t)
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   144
{
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   145
	void* ret;
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   146
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   147
	if (t == NULL) return NULL;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   148
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   149
	WaitForSingleObject(t->thread, INFINITE);
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   150
	CloseHandle(t->thread);
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   151
	ret = t->ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   152
	free(t);
2286
acb76b379e72 (svn r2810) Threads may now return information when they terminate using a void*.
tron
parents: 2285
diff changeset
   153
	return ret;
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   154
}
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   155
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6230
diff changeset
   156
void OTTDExitThread()
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   157
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   158
	ExitThread(0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4298
diff changeset
   159
}
2285
3193cbd1ba88 (svn r2809) Implement more generic threading functions, which allow more than one thread
tron
parents:
diff changeset
   160
#endif