(file) Return to Mutex.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 a.dunfey 1.2.2.1 //%2006////////////////////////////////////////////////////////////////////////
  2 mike     1.2     //
  3                  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4                  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5                  // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6                  // IBM Corp.; EMC Corporation, The Open Group.
  7                  // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8                  // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9                  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10                  // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 a.dunfey 1.2.2.1 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12                  // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike     1.2     //
 14                  // Permission is hereby granted, free of charge, to any person obtaining a copy
 15                  // of this software and associated documentation files (the "Software"), to
 16                  // deal in the Software without restriction, including without limitation the
 17                  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18                  // sell copies of the Software, and to permit persons to whom the Software is
 19                  // furnished to do so, subject to the following conditions:
 20 a.dunfey 1.2.2.1 // 
 21 mike     1.2     // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22                  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23                  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24                  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25                  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26                  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27                  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28                  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29                  //
 30                  //==============================================================================
 31                  //
 32                  // Author: Mike Day (mdday@us.ibm.com)
 33                  //
 34                  // Modified By: Markus Mueller
 35                  //              Ramnath Ravindran (Ramnath.Ravindran@compaq.com)
 36                  //              David Eger (dteger@us.ibm.com)
 37                  //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101
 38                  //              Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
 39                  //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 40                  //              David Dillard, VERITAS Software Corp.
 41                  //                  (david.dillard@veritas.com)
 42 mike     1.2     //              Aruran, IBM (ashanmug@in.ibm.com) for BUG# 3518
 43                  //
 44                  //%/////////////////////////////////////////////////////////////////////////////
 45                  
 46                  #ifndef Pegasus_Mutex_h
 47                  #define Pegasus_Mutex_h
 48                  
 49                  #include <Pegasus/Common/Config.h>
 50                  #include <Pegasus/Common/Linkage.h>
 51                  #include <Pegasus/Common/IPCTypes.h>
 52                  
 53                  PEGASUS_NAMESPACE_BEGIN
 54                  
 55                  class PEGASUS_COMMON_LINKAGE Mutex
 56                  {
 57                  public:
 58                  
 59                      Mutex();
 60                      Mutex(int type);
 61                  
 62                      ~Mutex();
 63 mike     1.2     
 64                      // block until gaining the lock - throw a deadlock
 65                      // exception if process already holds the lock
 66                      // @exception Deadlock
 67                      // @exception WaitFailed
 68                      void lock(PEGASUS_THREAD_TYPE caller);
 69                  
 70                      // try to gain the lock - lock succeeds immediately if the
 71                      // mutex is not already locked. throws an exception and returns
 72                      // immediately if the mutex is currently locked.
 73                      // @exception Deadlock
 74                      // @exception AlreadyLocked
 75                      // @exception WaitFailed
 76                      void try_lock(PEGASUS_THREAD_TYPE caller);
 77                  
 78                      // wait for milliseconds and throw an exception then return if the wait
 79                      // expires without gaining the lock. Otherwise return without throwing an
 80                      // exception.
 81                      // @exception Deadlock
 82                      // @exception TimeOut
 83                      // @exception WaitFailed
 84 mike     1.2         void timed_lock( Uint32 milliseconds, PEGASUS_THREAD_TYPE caller);
 85                  
 86                      // unlock the semaphore
 87                      // @exception Permission
 88                      void unlock();
 89                  
 90                      inline PEGASUS_THREAD_TYPE get_owner() { return(_mutex.owner); }
 91                  
 92                  private:
 93                      inline void _set_owner(PEGASUS_THREAD_TYPE owner) { _mutex.owner = owner; }
 94                      PEGASUS_MUTEX_HANDLE _mutex;
 95                      PEGASUS_MUTEX_HANDLE & _get_handle()
 96                      {
 97                          return _mutex;
 98                      }
 99                  
100                      // Hide the assignment operator to avoid implicit use of the default
101                      // assignment operator.  Do not use this method.
102                      Mutex& operator=(const Mutex& original) {return *this;}
103                  
104                      // Hide the copy constructor to avoid implicit use of the default
105 mike     1.2         // copy constructor.  Do not use this method.
106                      Mutex(const Mutex& _mutex);
107                  
108                      friend class Condition;
109                  };
110                  
111                  PEGASUS_NAMESPACE_END
112                  
113                  #endif /* Pegasus_Mutex_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2