home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mandlcpp.zip / process.h < prev    next >
C/C++ Source or Header  |  1993-06-24  |  2KB  |  89 lines

  1. #ifndef PROCESS_H
  2. #define PROCESS_H
  3.  
  4. #define INCL_DOSSEMAPHORES
  5. #define INCL_DOSPROCESS
  6.  
  7.  
  8. #include "tree.h"
  9.  
  10.  
  11. class process;
  12. class threadTree;
  13. class windowTree;
  14.  
  15.  
  16. #define idForeachThreadLast idForeachChainElementLast
  17.  
  18.  
  19. #define idGetChainElementThreadThis 0
  20. #define idGetChainElementThreadPTIB 1
  21. //#define idGetChainElementThreadPProcess 2
  22. #define idGetChainElementThreadLast 1
  23. class thread:public construct, public chainElement
  24. {    public:
  25.     PTIB pTIB;
  26.     process *pProcess;        // Backpointer
  27.     // The first thread which is already started
  28.     // should not be created using DosCreateThread()
  29.     // bCreate = FALSE should be used for the first thread
  30.     thread(Boolean bCreate, process *pProcessNew);
  31.     // Calls every time DosCreateThread
  32.     // Can be used if the thread will not be bound to the process
  33.     // thread chain, but to a window thread chain
  34.     thread(process *pProcessNew, chain *pParent);
  35.     // DosCreateThread will be called during processing
  36.     // of thread constructor.
  37.     // Then the thread waits until startThread() was been called.
  38.     // This is done, to avoid calling thread.run() before the
  39.     // constructor of the derived class returns.
  40.     void startThread(void)
  41.     {    DosPostEventSem(hEventConstructed);
  42.     }
  43.     void createThread(void);
  44.     HEV hEventConstructed;
  45.     virtual ~thread(void);
  46.     virtual void *getChainElementMember(unsigned int iMsg)
  47.     {    switch (iMsg)
  48.         {    default:
  49.                 return chainElement::getChainElementMember(iMsg);
  50.             case idGetChainElementThreadThis:
  51.                 return (void*)this;
  52.             case idGetChainElementThreadPTIB:
  53.                 return (void*)pTIB;
  54.             //case idGetChainElementThreadPProcess:
  55.                 //return (void*)pProcess;
  56.         }
  57.     }
  58. };
  59.  
  60.  
  61. #define idGetChainProcessThis 0
  62. #define idGetChainProcessLast 1
  63. class process:public construct, public chain
  64. {    public:
  65.     process(int argc, char **argv);
  66.     // thread with tid == 1
  67.     thread *pProcessThread;
  68.     // process info block
  69.     PPIB pPIB;
  70.     char **argv;
  71.     int argc;
  72.     virtual ~process(void);
  73.     virtual Boolean create(void);
  74.     void doSomething(void);
  75.     void destruct(void);
  76.     virtual void *getChainMember(unsigned int iMsg)
  77.     {    switch (iMsg)
  78.         {    default:
  79.                 abort();
  80.                 return "Hallo Peter";
  81.             case idGetChainProcessThis:
  82.                 return (void*)this;
  83.         }
  84.     }
  85. };
  86.  
  87.  
  88. #endif /* !PROCESS_H */
  89.