home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oclsrc15.zip / OCL / Include / OMuxWaitSem.hpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  4KB  |  122 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OMuxWaitSem.hpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30. // $Header: W:/Projects/OCL/Include/rcs/OMuxWaitSem.hpp 1.50 1996/08/11 23:47:23 B.STEIN Release $
  31.  
  32. #ifndef OMUXWAITSEM_INCLUDED
  33.   #define OMUXWAITSEM_INCLUDED
  34.  
  35.  
  36. #ifndef OVIOEXCEPTION_INCLUDED
  37.   #include <OVioException.hpp>
  38. #endif
  39.  
  40.  
  41. #ifndef ONSEM_INCLUDED
  42.   #include <ONSem.hpp>
  43. #endif
  44.  
  45. #ifndef OMUXSEM_INCLUDED
  46.   #include <OMuxSem.hpp>
  47. #endif
  48.  
  49.  
  50. // in case of any return value !TRUE check muxwaitState for error number
  51.  
  52.  
  53. typedef class OMuxWaitSem *pOMuxWaitSem;
  54.  
  55. class __CPP_EXPORT__ OMuxWaitSem
  56.   : public OCLObject
  57. {
  58.  private:
  59.    HMUX                   hmux;
  60.  
  61.  public:
  62.    ULONG                  muxwaitState;
  63.  
  64.  
  65.  enum OMuxWaitSemActions {
  66.                           open = 0,
  67.                           create
  68.                          };
  69.  
  70.  enum OMuxWaitOptions    {
  71.                           nowait = SEM_IMMEDIATE_RETURN,
  72.                           indefinite = SEM_INDEFINITE_WAIT,
  73.                           waitAll = DCMW_WAIT_ALL,
  74.                           waitAny = DCMW_WAIT_ANY,
  75.                           shared = DC_SEM_SHARED
  76.                          };
  77.  
  78.  OMuxWaitSem             (HMUX handle) throw (OVioException&);
  79.  
  80.  OMuxWaitSem             (PCSZ name,             // named MuxWaitSem name
  81.                           ULONG numSem,          // number of semaphores in semArray
  82.                           PSEMRECORD semArray,   // array of semaphores
  83.                           ULONG action = OMuxWaitSem::create,
  84.                           ULONG attrib = OMuxWaitSem::waitAny | OMuxWaitSem::shared)
  85.                          throw (OVioException&);
  86.  
  87.  virtual
  88.     ~OMuxWaitSem         ();
  89.  
  90.  virtual
  91.     PSZ isOfType         () const;
  92.  
  93.  ULONG
  94.     waitMuxWaitSem       (ULONG waitFlag = OMuxWaitSem::indefinite);
  95.                          // lets OMuxWaitSem wait
  96.                          // returns posted or last posted event semaphore
  97.  BOOL
  98.     openMuxWaitSem       (HMUX handle),
  99.     openMuxWaitSem       (PCSZ name),
  100.     closeMuxWaitSem      (),
  101.     addSemaphore         (PSEMRECORD record),  // add semaphore to wait list
  102.     addSemaphore         (ONSem *sema),        // add ONSem object to wait list
  103.     addSemaphore         (OMuxSem *sema),      // add OMuxSem object to wait list
  104.     delSemaphore         (HSEM handle),        // delete semaphore from the wait list
  105.     queryMuxWaitSem      (PULONG num,          // return number of semaphores in wait list
  106.                           PSEMRECORD semArray, // return array of semapores in wait list
  107.                           PULONG attributes);  // return creation flags of current OMuxWaitSem
  108.  
  109.  void
  110.     setMuxWaitSemHandle  (HMUX handle);
  111.  HMUX
  112.     getMuxWaitSemHandle  ();
  113. };
  114.  
  115.  
  116.  
  117.  
  118.  
  119. #endif // OMUXWAITSEM_INCLUDED
  120.  
  121. // end of source
  122.