summaryrefslogtreecommitdiff
path: root/src/thread_os2.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-14 19:54:33 +0000
committerrubidium <rubidium@openttd.org>2008-04-14 19:54:33 +0000
commit12188e7a5dde4cdd4304b3e738b7905e55f3ad9a (patch)
treea38226d767be0babf008f3304e7a61a4a00af2aa /src/thread_os2.cpp
parenta8008db23daf504af9f313ff0c53c5b89e756e05 (diff)
downloadopenttd-12188e7a5dde4cdd4304b3e738b7905e55f3ad9a.tar.xz
(svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable.
Diffstat (limited to 'src/thread_os2.cpp')
-rw-r--r--src/thread_os2.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/thread_os2.cpp b/src/thread_os2.cpp
new file mode 100644
index 000000000..29b33557f
--- /dev/null
+++ b/src/thread_os2.cpp
@@ -0,0 +1,80 @@
+/* $Id$ */
+
+/** @file thread_os2.cpp OS2 implementation of Threads. */
+
+#include "stdafx.h"
+#include "thread.h"
+
+#if 0
+#include "debug.h"
+#include "core/alloc_func.hpp"
+#include <stdlib.h>
+
+#define INCL_DOS
+#include <os2.h>
+#include <process.h>
+
+struct OTTDThread {
+ TID thread;
+ OTTDThreadFunc func;
+ void *arg;
+ void *ret;
+};
+
+static void Proxy(void *arg)
+{
+ OTTDThread *t = (OTTDThread *)arg;
+ t->ret = t->func(t->arg);
+}
+
+OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg)
+{
+ OTTDThread *t = MallocT<OTTDThread>(1);
+
+ t->func = function;
+ t->arg = arg;
+ t->thread = _beginthread(Proxy, NULL, 32768, t);
+ if (t->thread != (TID)-1) {
+ return t;
+ } else {
+ free(t);
+ return NULL;
+ }
+}
+
+void *OTTDJoinThread(OTTDThread *t)
+{
+ if (t == NULL) return NULL;
+
+ DosWaitThread(&t->thread, DCWW_WAIT);
+ void *ret = t->ret;
+ free(t);
+ return ret;
+}
+
+void OTTDExitThread()
+{
+ _endthread();
+}
+
+#endif
+
+/* static */ ThreadObject *ThreadObject::New(OTTDThreadFunc proc, void *param)
+{
+ return NULL;
+}
+
+/* static */ ThreadObject *ThreadObject::AttachCurrent()
+{
+ return NULL;
+}
+
+/* static */ uint ThreadObject::CurrentId()
+{
+ return -1;
+}
+
+/* static */ ThreadSemaphore *ThreadSemaphore::New()
+{
+ return NULL;
+}