home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Timing / Timeout.h < prev    next >
Encoding:
Text File  |  1998-06-18  |  465 b   |  33 lines  |  [TEXT/CWIE]

  1. // Timeout.h
  2.  
  3. #ifndef Timeout_h
  4. #define Timeout_h
  5.  
  6. #ifndef Waiter_h
  7. #include "Waiter.h"
  8. #endif
  9. #ifndef Race_h
  10. #include "Race.h"
  11. #endif
  12.  
  13. /*
  14.     A Timeout wraps a timer around a Task.  You use it like this:
  15.         Timeout timeout;
  16.         timeout( someTask, Microsecs(5) )  // or Millisecs(5)
  17. */
  18.  
  19. class Timeout
  20.   {
  21.     private:
  22.         Waiter wait;
  23.         Race2 race;
  24.     
  25.     public:
  26.         Task *operator()( Task *task, WaitLength time )
  27.           {
  28.             return race( task, wait( time ), 1 );
  29.           }
  30.   };
  31.  
  32. #endif
  33.