00001 #ifndef __OUC_LOCK_HH__ 00002 #define __OUC_LOCK_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O u c L o c k . h h */ 00006 /* */ 00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdOucLock.hh 22437 2008-03-04 14:35:16Z rdm $ 00014 00015 #include "XrdSys/XrdSysPthread.hh" 00016 00017 class XrdOucLock 00018 { 00019 public: 00020 XrdOucLock(XrdSysMutex *mp) 00021 {Mutex = mp; Mutex->Lock(); isLocked = 1;} 00022 ~XrdOucLock() {if (isLocked) Mutex->UnLock();} 00023 00024 private: 00025 00026 XrdSysMutex *Mutex; 00027 int isLocked; 00028 }; 00029 #endif