00001 #ifndef __XRDFILECACHE_STATS_HH__ 00002 #define __XRDFILECACHE_STATS_HH__ 00003 00004 //---------------------------------------------------------------------------------- 00005 // Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University 00006 // Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman 00007 //---------------------------------------------------------------------------------- 00008 // XRootD is free software: you can redistribute it and/or modify 00009 // it under the terms of the GNU Lesser General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // XRootD is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Lesser General Public License 00019 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00020 //---------------------------------------------------------------------------------- 00021 00022 #include "XrdOuc/XrdOucCache.hh" 00023 #include "XrdSys/XrdSysPthread.hh" 00024 00025 namespace XrdFileCache 00026 { 00027 //---------------------------------------------------------------------------- 00029 //---------------------------------------------------------------------------- 00030 class Stats 00031 { 00032 public: 00033 //---------------------------------------------------------------------- 00035 //---------------------------------------------------------------------- 00036 Stats() { 00037 m_BytesDisk = m_BytesRam = m_BytesMissed = 0; 00038 } 00039 00040 long long m_BytesDisk; 00041 long long m_BytesRam; 00042 long long m_BytesMissed; 00043 00044 inline void AddStats(Stats &Src) 00045 { 00046 m_MutexXfc.Lock(); 00047 00048 m_BytesDisk += Src.m_BytesDisk; 00049 m_BytesRam += Src.m_BytesRam; 00050 m_BytesMissed += Src.m_BytesMissed; 00051 00052 m_MutexXfc.UnLock(); 00053 } 00054 00055 Stats Clone() 00056 { 00057 Stats ret; 00058 m_MutexXfc.Lock(); 00059 ret = *this; 00060 m_MutexXfc.UnLock(); 00061 return ret; 00062 } 00063 00064 private: 00065 XrdSysMutex m_MutexXfc; 00066 }; 00067 } 00068 00069 #endif 00070