XrdSysXSLock.hh

Go to the documentation of this file.
00001 #ifndef __SYS_XSLOCK_HH__
00002 #define __SYS_XSLOCK_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                       X r d S y s X S 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: XrdSysXSLock.hh 22437 2008-03-04 14:35:16Z rdm $
00014 
00015 #include <errno.h>
00016 #include "XrdSys/XrdSysPthread.hh"
00017 
00018 // These are valid usage options
00019 //
00020 enum XrdSysXS_Type {xs_None = 0, xs_Shared = 1, xs_Exclusive = 2};
00021 
00022 // This class implements the shared lock. Any number of readers are allowed
00023 // by requesting a shared lock. Only one exclusive writer is allowed by
00024 // requesting an exclusive lock. Up/downgrading is not supported.
00025 //
00026 class XrdSysXSLock
00027 {
00028 public:
00029 
00030 void        Lock(const XrdSysXS_Type usage);
00031 
00032 void      UnLock(const XrdSysXS_Type usage=xs_None);
00033 
00034           XrdSysXSLock()
00035                {cur_usage = xs_None; cur_count = 0;
00036                 exc_wait = 0; shr_wait = 0; toggle = 0;}
00037 
00038          ~XrdSysXSLock();
00039 
00040 private:
00041 
00042 XrdSysXS_Type cur_usage;
00043 int           cur_count;
00044 int           exc_wait;
00045 int           shr_wait;
00046 int           toggle;
00047 
00048 XrdSysMutex       LockContext;
00049 XrdSysSemaphore   WantShr;
00050 XrdSysSemaphore   WantExc;
00051 };
00052 #endif

Generated on Tue Jul 5 14:47:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1