2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define _WIN32_WINNT 0x501
28 typedef struct timespec
30 long tv_sec; /* seconds */
31 long tv_nsec; /* nanoseconds */
33 #define WINDOWS_TIME_BASE_OFFSET 116444736000000000
37 class ThreadWin : public Thread
40 // Override this method in derived classes
41 virtual void threadMethod()=0;
42 virtual void threadPostStopCleanup()=0;
44 // Methods to use from outside the thread
45 int threadStart(); // start the thread. threadMethod() will be called in derived class
46 void threadStop(); // stop the thread nicely. thread will be stopped when it next calls threadCheckExit()
47 void threadCancel(); // stop thread immediately. thread will be stopped at the next cancellation point
48 void threadSignal(); // releases a thread that has called threadWaitForSignal
49 void threadSignalNoLock(); // same as above but without locking guarantees. probably not a good idea.
51 // Methods to use from inside the thread
52 void threadSetKillable(); // allows threadCancel() to work
53 void threadCheckExit(); // terminates thread if threadStop() has been called
54 void threadWaitForSignal(); // pauses thread until threadSignal() is called
55 void threadWaitForSignalTimed(struct timespec*); // pauses thread until threadSignal() is called or timer expires
56 void threadLock(); // locks the mutex used for internal cond/signal stuff
57 void threadUnlock(); // unlocks.
59 // Internal bits and pieces
63 HANDLE threadCondMutex;