home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / Threads Interface / CMainThread.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-03  |  1.4 KB  |  51 lines  |  [TEXT/KAHL]

  1. /***
  2.  * CMainThread.h
  3.  *
  4.  *  Implement a dummy thread that is really the main thread.  Mostly, we disable
  5.  *  most thread calls.  This object *MUST* be created by the ThreadManager only.
  6.  *  It relies on being created in the main thread!!!!!
  7.  *        Copyright © Gordon Watts 1994 (gwatts@fnal.fnal.gov)
  8.  *
  9.  ***/
  10. #pragma once
  11.  
  12. #include "CGWObject.h"
  13. #include <Threads.h>
  14.  
  15. class CMainThread;
  16.  
  17. typedef struct {
  18.     long            theAppA5;
  19.     CMainThread        *threadObj;
  20. } switcherInfo;
  21.  
  22. class CMainThread : public CGWObject {
  23. private:
  24.     short            savedLastError;            // Stuff saved by thread switcher routines
  25.     long            savedLastMessage;
  26.     char            savedDefaultPropagation;
  27.     void            *savedTopHandler;
  28.  
  29. protected:
  30.     ThreadID        theThread;
  31.     switcherInfo    *theSInfo;
  32.  
  33.     void            SetupThreadSwitcher (Boolean useCurrentValues);
  34.                                                 // Setup thread switch handler.
  35.     void            KillThreadSwitcher (void);    // Turn it off.
  36.  
  37.     static pascal void        switcherCallBackIn (ThreadID thread, void *ptr);
  38.     void            DoSwitchIn (void);            // Restore globals...
  39.     static pascal void        switcherCallBackOut (ThreadID thread, void *ptr);
  40.     void            DoSwitchOut (void);            // Kill off globals
  41.  
  42. public:
  43.                     CMainThread (void);            // Init the stuff in this thread
  44.                     ~CMainThread (void);        // Kill off everything in this thread
  45.  
  46.     Boolean            isRunning (void);            // Return true if we are up and running
  47.  
  48.     void            Start (void);                // Do the setup we need
  49.     void            Kill(void);                // Kill the thread.
  50.  
  51. };