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

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OMuxSem.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/OMuxSem.hpp 1.50 1996/08/11 23:47:23 B.STEIN Release $
  31.  
  32. #ifndef OMUXSEM_INCLUDED
  33.   #define OMUXSEM_INCLUDED
  34.  
  35.  
  36.  
  37. #ifndef OSTRING_INCLUDED
  38.   #include <OString.hpp>
  39. #endif
  40.  
  41. #ifndef OVIOEXCEPTION_INCLUDED
  42.   #include <OVioException.hpp>
  43. #endif
  44.  
  45.  
  46. typedef class OMuxSem *pOMuxSem;
  47.  
  48.  
  49. // in case of any return value !TRUE check muxState for error number
  50.  
  51.  
  52. class __CPP_EXPORT__ OMuxSem
  53.   : public OCLObject
  54. {
  55.  private:
  56.    OString               muxName;
  57.    HMTX                  hmtx;
  58.  
  59.  public:
  60.    ULONG                 muxState;
  61.  
  62.    enum OMuxSemState    {
  63.                          immediate  = SEM_IMMEDIATE_RETURN,
  64.                          indefinite = SEM_INDEFINITE_WAIT
  65.                         };
  66.  
  67.    enum OMuxSemAction   {
  68.                          create = 0,
  69.                          open
  70.                         };
  71.  
  72.    OMuxSem              (HMTX handle)        throw (OVioException&);
  73.  
  74.    OMuxSem              (PCSZ name,            
  75.                          ULONG action = OMuxSem::create,
  76.                          BOOL shared = TRUE) throw (OVioException&);  
  77.  
  78.    virtual
  79.       ~OMuxSem          ();
  80.  
  81.    virtual
  82.       PSZ isOfType      () const; 
  83.  
  84.  
  85.    BOOL
  86.       openMuxSem        (HMTX handle),
  87.       openMuxSem        (PCSZ name),
  88.       closeMuxSem       (),
  89.       requestMuxSem     (ULONG timeOut = OMuxSem::indefinite),
  90.       releaseMuxSem     (),
  91.       queryMuxSem       (PPID pid,  // returns current owners process id
  92.                          PTID tid); // returns current owners thread id
  93.  
  94.    void setMuxSemHandle (HMTX handle);
  95.    HMTX getMuxSemHandle ();
  96. };
  97.  
  98.  
  99.  
  100.  
  101. #endif // OMUXSEM_INCLUDED
  102.  
  103. // end of source
  104.