00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2013 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 00019 #ifndef __XRD_CL_FILE_TIMER_HH__ 00020 #define __XRD_CL_FILE_TIMER_HH__ 00021 00022 #include "XrdSys/XrdSysPthread.hh" 00023 #include "XrdCl/XrdClTaskManager.hh" 00024 00025 namespace XrdCl 00026 { 00027 class FileStateHandler; 00028 00029 //---------------------------------------------------------------------------- 00031 //---------------------------------------------------------------------------- 00032 class FileTimer: public Task 00033 { 00034 public: 00035 //------------------------------------------------------------------------ 00037 //------------------------------------------------------------------------ 00038 FileTimer() 00039 { 00040 SetName( "FileTimer task" ); 00041 } 00042 00043 //------------------------------------------------------------------------ 00045 //------------------------------------------------------------------------ 00046 virtual ~FileTimer() 00047 { 00048 } 00049 00050 //------------------------------------------------------------------------ 00052 //------------------------------------------------------------------------ 00053 void RegisterFileObject( FileStateHandler *file ) 00054 { 00055 XrdSysMutexHelper scopedLock( pMutex ); 00056 pFileObjects.insert( file ); 00057 } 00058 00059 //------------------------------------------------------------------------ 00061 //------------------------------------------------------------------------ 00062 void UnRegisterFileObject( FileStateHandler *file ) 00063 { 00064 XrdSysMutexHelper scopedLock( pMutex ); 00065 pFileObjects.erase( file ); 00066 } 00067 00068 //------------------------------------------------------------------------ 00070 //------------------------------------------------------------------------ 00071 void Lock() 00072 { 00073 pMutex.Lock(); 00074 } 00075 00076 //------------------------------------------------------------------------ 00078 //------------------------------------------------------------------------ 00079 void UnLock() 00080 { 00081 pMutex.UnLock(); 00082 } 00083 00084 //------------------------------------------------------------------------ 00086 //------------------------------------------------------------------------ 00087 virtual time_t Run( time_t now ); 00088 00089 private: 00090 std::set<FileStateHandler*> pFileObjects; 00091 XrdSysMutex pMutex; 00092 }; 00093 } 00094 00095 #endif // __XRD_CL_FILE_TIMER_HH__