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

  1 karl  1.3 //%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 karl  1.3 // 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 karl  1.3 // 
 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 mike  1.3.12.1     void lock(PEGASUS_THREAD_TYPE caller = pegasus_thread_self());
 69 mike  1.2      
 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 mike  1.3.12.1     void try_lock(PEGASUS_THREAD_TYPE caller = pegasus_thread_self());
 77 mike  1.2      
 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.3.12.1     void timed_lock( 
 85                	Uint32 milliseconds, 
 86                	PEGASUS_THREAD_TYPE caller = pegasus_thread_self());
 87 mike  1.2      
 88                    // unlock the semaphore
 89                    // @exception Permission
 90                    void unlock();
 91                
 92                    inline PEGASUS_THREAD_TYPE get_owner() { return(_mutex.owner); }
 93                
 94                private:
 95                    inline void _set_owner(PEGASUS_THREAD_TYPE owner) { _mutex.owner = owner; }
 96                    PEGASUS_MUTEX_HANDLE _mutex;
 97                    PEGASUS_MUTEX_HANDLE & _get_handle()
 98                    {
 99                        return _mutex;
100                    }
101                
102                    // Hide the assignment operator to avoid implicit use of the default
103                    // assignment operator.  Do not use this method.
104                    Mutex& operator=(const Mutex& original) {return *this;}
105                
106                    // Hide the copy constructor to avoid implicit use of the default
107                    // copy constructor.  Do not use this method.
108 mike  1.2          Mutex(const Mutex& _mutex);
109                
110                    friend class Condition;
111                };
112                
113                PEGASUS_NAMESPACE_END
114                
115                #endif /* Pegasus_Mutex_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2