Threaded plugin sample code, not part of the build

git-svn-id: svn://10.0.0.236/trunk@115924 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
av%netscape.com
2002-03-06 03:37:15 +00:00
parent 33faee2a61
commit 482e8bd78a
5 changed files with 177 additions and 0 deletions

View File

@@ -34,3 +34,57 @@
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __THREAD_H__
#define __THREAD_H__
typedef enum {
ts_dead = 0,
ts_ready,
ts_busy
} ThreadState;
class CThread {
private:
HANDLE mThread;
DWORD mID;
HANDLE mEventThreadInitializationFinished;
HANDLE mEventThreadShutdownFinished;
DWORD mInitTimeOut;
DWORD mShutTimeOut;
HANDLE mEventDo;
ThreadState mState;
protected:
int mAction;
public:
BOOL setInitEvent();
BOOL setShutEvent();
BOOL isAlive();
BOOL isBusy();
HANDLE getHandle();
void run();
// outside thread interface
CThread(DWORD aInitTimeOut = INFINITE, DWORD aShutTimeOut = INFINITE);
virtual ~CThread();
BOOL open(CThread * aThread);
void close(CThread * aThread);
BOOL tryAction(int aAction);
BOOL doAction(int aAction);
// virtuals
virtual BOOL init() = 0;
virtual void shut() = 0;
virtual void dispatch() = 0;
};
BOOL InitThreadLib(HINSTANCE aInstance);
void ShutThreadLib(HINSTANCE aInstance);
#endif // THREAD_HPP__