home *** CD-ROM | disk | FTP | other *** search
- #ifndef __THREADSUPPORT__
- #define __THREADSUPPORT__
- #pragma once
-
- #include "ToolBox.h"
- #include "ThreadContext.h"
-
- #include <Threads.h>
-
- #ifdef __MWERKS__
-
- // set to a non-zero value to get profiling functions
- #ifndef CW_THREAD_PROFILE
- #define CW_THREAD_PROFILE 0
- #endif
-
- #if __MWERKS__ >= 0x0800
- #define CW7_EXCEPTIONS 0
- #else
- #define CW7_EXCEPTIONS 1
- #endif
-
- #if !THREAD_ZEROOVERHEAD_EXCEPTIONS
- #include <MWException.h>
- #endif
-
- #endif
-
-
-
- class TThread : private ListLink
- {
- protected:
- friend class ThreadContext;
-
- ThreadID fThreadID;
- LinkedListOf<ThreadContext> fContextList;
-
- #if !GENERATINGCFM
- long fSavedA5;
- #endif
-
- #if CW_THREAD_PROFILE
- ProfilerRefT fProfilerRef; // Profiler context
- #endif
-
- #if CW7_EXCEPTIONS
- ExceptionState fExceptionState;
- char fCatchBuffer[CATCH_BUFSIZE];
- #endif
-
- public:
- TThread(ThreadID id);
- virtual ~TThread();
-
- virtual void SwitchIn(void);
- virtual void SwitchOut(void);
- virtual void Terminate(void);
-
- protected:
- static pascal void SwitchInProc(ThreadID threadBeingSwitched, void *switchProcParam);
- static pascal void SwitchOutProc(ThreadID threadBeingSwitched, void *switchProcParam);
- static pascal void TerminationProc(ThreadID threadTerminated, void *terminationProcParam);
-
-
- public:
- static TThread* GetThreadHandler(ThreadID aThreadID);
-
- static LinkedListOf<TThread> fgThreadList; // Global thread list
-
- private: // required overrides for TListLink
- void* GetObjectPtr();
- };
-
-
-
-
-
- #endif // __THREADSUPPORT__
-
-