home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Tasks / TaskLife.h < prev   
Encoding:
Text File  |  1998-06-17  |  1020 b   |  57 lines  |  [TEXT/CWIE]

  1. // TaskLife.h
  2.  
  3. #ifndef TaskLife_h
  4. #define TaskLife_h
  5.  
  6. #ifndef Completor_h
  7. #include "Completor.h"
  8. #endif
  9. #ifndef Deferer_h
  10. #include "Deferer.h"
  11. #endif
  12. #ifndef ApplicationTaskQueue_h
  13. #include "ApplicationTaskQueue.h"
  14. #endif
  15.  
  16. class Task;
  17.  
  18. class TaskLife
  19.   {
  20.     friend class Task;
  21.     
  22.     private:
  23.         Task *volatile task;
  24.         Completor completor;
  25.         volatile bool complete;
  26.         
  27.         BoundMethod1< TaskLife, DeferredTaskTime > runDeferredCompletor;
  28.         BoundMethod1< TaskLife, ApplicationTime > runApplicationCompletor;
  29.  
  30.         Deferer deferer;
  31.         ApplicationTaskQueue::Link applicationLink;
  32.         
  33.         void QueueCompletor();
  34.         void FinishTask();
  35.         
  36.         void RunCompletor( DeferredTaskTime );
  37.         void RunCompletor( ApplicationTime );
  38.         
  39.         // not implemented:
  40.             TaskLife( const TaskLife& );
  41.             void operator=( const TaskLife& );
  42.         
  43.     public:
  44.         TaskLife();
  45.         ~TaskLife();
  46.         
  47.         void Launch( Task *, Completor = Completor() );
  48.         void Kill();
  49.         
  50.         bool Complete() const        { return complete; }
  51.  
  52.         void WaitForCompletion() const;
  53.         void KillAndWait();
  54.   };
  55.  
  56. #endif
  57.