7 #define WIN32_LEAN_AND_MEAN
24 #if !defined(__WIN32__)
28 public enum ThreadPriority
43 #if defined(__WIN32__)
49 #if defined(__WIN32__)
63 uint returnCode = this.returnCode = Main();
65 #if defined(__WIN32__)
79 virtual uint Main(void);
86 #if !defined(__WIN32__)
90 // printf("Creating %s thread\n", _class.name);
91 #if defined(__WIN32__)
93 handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadCallBack, this, 0, &id);
97 /*pthread_attr_t attr;
98 pthread_attr_init(&attr);
99 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);*/ // Default attribute ???
100 error = pthread_create(&id, null /*&attr*/, (void *)ThreadCallBack, this);
102 printf("Error %d creating a thread\n", error);
110 #if defined(__WIN32__)
113 TerminateThread(handle, 0);
118 pthread_kill(id, SIGQUIT);
129 #if defined(__WIN32__)
130 if(WaitForSingleObject(handle, INFINITE /*2000*/) == WAIT_TIMEOUT)
131 PrintLn("Thread not returning?\n");
136 pthread_join(id, NULL);*/
143 void SetPriority(ThreadPriority priority)
145 #if defined(__WIN32__)
146 SetThreadPriority(handle, priority);
149 struct sched_param param;
150 int policy = (priority > 0) ? SCHED_RR : SCHED_OTHER;
151 param.sched_priority = (priority > 0) ? (priority * 99 / 15) : 0;
152 pthread_setschedparam(id, policy, ¶m);
157 property bool created { get { return started; } };