00001 // @(#)root/base:$Id: TVirtualMutex.cxx 20877 2007-11-19 11:17:07Z rdm $ 00002 // Author: Fons Rademakers 14/02/2002 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // TVirtualMutex // 00015 // // 00016 // This class implements a mutex interface. The actual work is done via // 00017 // TMutex which is available as soon as the thread library is loaded. // 00018 // // 00019 // and // 00020 // // 00021 // TLockGuard // 00022 // // 00023 // This class provides mutex resource management in a guaranteed and // 00024 // exception safe way. Use like this: // 00025 // { // 00026 // TLockGuard guard(mutex); // 00027 // ... // do something // 00028 // } // 00029 // when guard goes out of scope the mutex is unlocked in the TLockGuard // 00030 // destructor. The exception mechanism takes care of calling the dtors // 00031 // of local objects so it is exception safe. // 00032 // // 00033 ////////////////////////////////////////////////////////////////////////// 00034 00035 #include "TVirtualMutex.h" 00036 00037 ClassImp(TVirtualMutex) 00038 ClassImp(TLockGuard) 00039 00040 // Global mutex set in TThread::Init protecting creation 00041 // of other (preferrably local) mutexes. Note that in this 00042 // concept gGlobalMutex must be used in TStorage to prevent 00043 // lockup of the system (see TMutex::Factory) 00044 TVirtualMutex *gGlobalMutex = 0;