home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C++ / Frameworks / Sprocket Framework DR2 / Sprocket Framework Interfaces / ThreadContext.h < prev    next >
Encoding:
Text File  |  1996-03-13  |  1.3 KB  |  69 lines  |  [TEXT/CWIE]

  1. // Sprocket Framework header file
  2. // ThreadContext.h
  3.  
  4.  
  5. #ifndef    _THREADCONTEXT_
  6. #define    _THREADCONTEXT_
  7.  
  8. #ifndef    __THREADS__
  9. #include <Threads.h>
  10. #endif
  11.  
  12. #ifdef    __MWERKS__
  13.  
  14.     // set to a non-zero value to get profiling functions
  15.     #ifndef CW_THREAD_PROFILE
  16.     #define CW_THREAD_PROFILE        0
  17.     #endif
  18.  
  19.     #if __MWERKS__ >= 0x0800
  20.         #define CW7_EXCEPTIONS 0
  21.     #else
  22.         #define CW7_EXCEPTIONS 1
  23.     #endif
  24.  
  25.     #if !THREAD_ZEROOVERHEAD_EXCEPTIONS
  26.     #include <MWException.h>
  27.     #endif
  28.  
  29. #endif
  30.  
  31.  
  32.  
  33. class    TThreadContext
  34. {
  35. protected:
  36.     ThreadID        fThreadID;
  37.     void*            fThreadResult;
  38.  
  39. #if !GENERATINGCFM
  40.     long            fSavedA5;
  41. #endif
  42.  
  43. #if CW_THREAD_PROFILE
  44.     ProfilerRefT    fProfilerRef;    // Profiler context
  45. #endif
  46.  
  47. #if CW7_EXCEPTIONS
  48.     ExceptionState    fExceptionState;
  49.     char            fCatchBuffer[CATCH_BUFSIZE];
  50. #endif
  51.  
  52. public:
  53.                     TThreadContext(void);
  54.     virtual            ~TThreadContext();
  55.  
  56.     virtual void    CreateThread(ThreadStyle threadStyle, ThreadEntryProcPtr threadEntry, Size stackSize, ThreadOptions options);
  57.  
  58.     virtual void    SwitchIn(void);
  59.     virtual void    SwitchOut(void);
  60.     virtual void    Terminate(void);
  61.     
  62. protected:
  63.     static pascal void SwitchInProc(ThreadID threadBeingSwitched, void *switchProcParam);
  64.     static pascal void SwitchOutProc(ThreadID threadBeingSwitched, void *switchProcParam);
  65.     static pascal void TerminationProc(ThreadID threadTerminated, void *terminationProcParam);
  66. };
  67.  
  68. #endif
  69.