src/thread_os2.cpp
changeset 8934 f46812d21fe6
child 9477 00be34b8e9fd
equal deleted inserted replaced
8933:c1f075679c2e 8934:f46812d21fe6
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file thread_os2.cpp OS2 implementation of Threads. */
       
     4 
       
     5 #include "stdafx.h"
       
     6 #include "thread.h"
       
     7 
       
     8 #if 0
       
     9 #include "debug.h"
       
    10 #include "core/alloc_func.hpp"
       
    11 #include <stdlib.h>
       
    12 
       
    13 #define INCL_DOS
       
    14 #include <os2.h>
       
    15 #include <process.h>
       
    16 
       
    17 struct OTTDThread {
       
    18 	TID thread;
       
    19 	OTTDThreadFunc func;
       
    20 	void *arg;
       
    21 	void *ret;
       
    22 };
       
    23 
       
    24 static void Proxy(void *arg)
       
    25 {
       
    26 	OTTDThread *t = (OTTDThread *)arg;
       
    27 	t->ret = t->func(t->arg);
       
    28 }
       
    29 
       
    30 OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg)
       
    31 {
       
    32 	OTTDThread *t = MallocT<OTTDThread>(1);
       
    33 
       
    34 	t->func = function;
       
    35 	t->arg  = arg;
       
    36 	t->thread = _beginthread(Proxy, NULL, 32768, t);
       
    37 	if (t->thread != (TID)-1) {
       
    38 		return t;
       
    39 	} else {
       
    40 		free(t);
       
    41 		return NULL;
       
    42 	}
       
    43 }
       
    44 
       
    45 void *OTTDJoinThread(OTTDThread *t)
       
    46 {
       
    47 	if (t == NULL) return NULL;
       
    48 
       
    49 	DosWaitThread(&t->thread, DCWW_WAIT);
       
    50 	void *ret = t->ret;
       
    51 	free(t);
       
    52 	return ret;
       
    53 }
       
    54 
       
    55 void OTTDExitThread()
       
    56 {
       
    57 	_endthread();
       
    58 }
       
    59 
       
    60 #endif
       
    61 
       
    62 /* static */ ThreadObject *ThreadObject::New(OTTDThreadFunc proc, void *param)
       
    63 {
       
    64 	return NULL;
       
    65 }
       
    66 
       
    67 /* static */ ThreadObject *ThreadObject::AttachCurrent()
       
    68 {
       
    69 	return NULL;
       
    70 }
       
    71 
       
    72 /* static */ uint ThreadObject::CurrentId()
       
    73 {
       
    74 	return -1;
       
    75 }
       
    76 
       
    77 /* static */ ThreadSemaphore *ThreadSemaphore::New()
       
    78 {
       
    79 	return NULL;
       
    80 }