]> git.vomp.tv Git - vompclient.git/blob - thread.h
Completion of move recording code. Fixes for dir counts, other bugs.
[vompclient.git] / thread.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #ifndef THREAD_H
22 #define THREAD_H
23
24 class Thread
25 {
26   protected:
27     // Override this method in classes derived from ThreadP or ThreadWin
28     virtual void threadMethod()=0;
29     virtual void threadPostStopCleanup()=0;
30
31     // Methods to use from outside the thread
32     virtual int threadStart()=0;    // start the thread. threadMethod() will be called in derived class
33     virtual void threadStop()=0;    // stop the thread nicely. thread will be stopped when it next calls threadCheckExit()
34     virtual void threadCancel()=0;  // stop thread immediately. thread will be stopped at the next cancellation point
35     virtual void threadSignal()=0;  // releases a thread that has called threadWaitForSignal
36     virtual void threadSignalNoLock()=0;  // same as above but without locking guarantees. probably not a good idea.
37     char threadIsActive(); // returns 1 if thread has been started but not stop() or cancel() 'd
38
39     // Methods to use from inside the thread
40     virtual void threadSetKillable()=0;    // allows threadCancel() to work
41     virtual void threadCheckExit()=0;      // terminates thread if threadStop() has been called
42     virtual void threadWaitForSignal()=0;  // pauses thread until threadSignal() is called
43     virtual void threadWaitForSignalTimed(struct timespec*)=0;  // pauses thread until threadSignal() is called or timer expires
44     virtual void threadLock()=0;           // locks the mutex used for internal cond/signal stuff
45     virtual void threadUnlock()=0;         // unlocks.
46
47     // Internal bits and pieces
48
49   protected:
50     char threadActive;
51
52   public:
53     Thread();
54     virtual ~Thread() {}
55     void threadInternalStart2();
56 };
57
58 #endif