home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / thread / signal / signal.hpp < prev   
Text File  |  1996-10-29  |  4KB  |  90 lines

  1. #ifndef _SIGNAL_
  2. #define _SIGNAL_
  3. /***************************************************************
  4. * FILE NAME: signal.hpp                                        *
  5. *                                                              *
  6. * DESCRIPTION:                                                 *
  7. *   This file contains the declaration(s) of the class(es):    *
  8. *     Signal - Portable event semaphore class.                 *
  9. *                                                              *
  10. * COPYRIGHT:                                                   *
  11. *   Licensed Materials - Property of Solution Frameworks       *
  12. *   Copyright (C) 1996, Solution Frameworks                    *
  13. *   All Rights Reserved                                        *
  14. ***************************************************************/
  15. #ifndef __IVBASE__
  16.   #include <ivbase.hpp>
  17. #endif
  18.  
  19. #ifndef _IHANDLE_
  20.   #include <ihandle.hpp>
  21. #endif
  22.  
  23. /*----------------------- SignalHandle -------------------------
  24. | Objects of this class are simple wrappers for OS/2's HEV or  |
  25. | Windows' event HANDLE.                                       |
  26. --------------------------------------------------------------*/
  27. class SignalHandle : public IHandle {
  28. public:
  29.   SignalHandle ( Value hev = 0 )
  30.     : IHandle( hev ) {
  31.     }
  32. };
  33.  
  34. /*-------------------------- Signal ----------------------------
  35. | Objects of this class represent "signals" that application   |
  36. | threads can post and wait on.  They correspond to operating  |
  37. | system event semaphores.                                     |
  38. |                                                              |
  39. | Signals can be in either of two states:                      |
  40. |   signalled - The signal has been set and subsequent wait    |
  41. |               requests will not block.                       |
  42. |   reset     - The signal has not been set; subsequent wait   |
  43. |               requests will block until the signal is posted.|
  44. |                                                              |
  45. | Signals have 3 other attributes that are fixed at the time   |
  46. | they are constructed:                                        |
  47. |   name          - Arbitrary identifier for the signal; named |
  48. |                   signals can be shared between processes.   |
  49. |   initial state - The signal can initially be signalled or   |
  50. |                   reset; the default is reset.               |
  51. --------------------------------------------------------------*/
  52. class Signal : public IVBase {
  53. typedef IVBase
  54.   Inherited;
  55. public:
  56. /*----------------- Constructors/Destructor --------------------
  57. | There are two constructors (with default arguments) that     |
  58. | permit a Signal to be constructed from any combination of    |
  59. | an initial state and/or name.                                |       
  60. --------------------------------------------------------------*/
  61.   Signal ( Boolean     signalled = false,
  62.            const char *name      = 0 );
  63.   Signal ( const char *name, 
  64.            Boolean     signalled = false );
  65.   ~Signal ( );
  66.  
  67. /*------------------------ Signalling --------------------------
  68. | You can manipulate Signals using these member functions:     |
  69. |   reset  - Reset so that subsequent wait requests block.     |
  70. |   signal - Set so tht subsequent wait requests don't block.  |
  71. |   wait   - Wait for the event to be signalled.               |
  72. --------------------------------------------------------------*/
  73. virtual Signal
  74.  &reset  ( ),
  75.  &signal ( ),
  76.  &wait   ( unsigned long timeout = 0xfffffffful );
  77.  
  78. private:
  79. void
  80.   initialize( Boolean, const char * );
  81.  
  82. SignalHandle
  83.   handle;
  84.  
  85.   Signal    ( const Signal & );
  86.   operator= ( const Signal & );
  87. };
  88.  
  89. #endif // __SIGNAL__
  90.