|
||||
File indexing completed on 2025-01-18 10:15:43
0001 #ifndef __XrdSysTimer__ 0002 #define __XrdSysTimer__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S y s T i m e r . h h */ 0006 /* */ 0007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 #ifndef WIN32 0033 #include <sys/time.h> 0034 #else 0035 #include <ctime> 0036 #include <Winsock2.h> 0037 #include "XrdSys/XrdWin32.hh" 0038 #endif 0039 0040 /* This include file describes the oo elapsed time interval interface. It is 0041 used by the oo Real Time Monitor, among others. 0042 */ 0043 0044 class XrdSysTimer { 0045 0046 public: 0047 struct timeval *Delta_Time(struct timeval &tbeg); 0048 0049 static time_t Midnight(time_t tnow=0); 0050 0051 inline int TimeLE(time_t tsec) {return StopWatch.tv_sec <= tsec;} 0052 0053 // The following routines return the current interval added to the 0054 // passed argument as well as returning the current Unix seconds 0055 // 0056 unsigned long Report(double &); 0057 unsigned long Report(unsigned long &); 0058 unsigned long Report(unsigned long long &); 0059 unsigned long Report(struct timeval &); 0060 0061 inline void Reset() {gettimeofday(&StopWatch, 0);} 0062 0063 inline time_t Seconds() {return StopWatch.tv_sec;} 0064 0065 inline void Set(struct timeval &tod) 0066 {StopWatch.tv_sec = tod.tv_sec; 0067 StopWatch.tv_usec = tod.tv_usec; 0068 } 0069 0070 static void Snooze(int seconds); 0071 0072 static char *s2hms(int sec, char *buff, int blen); 0073 0074 static int TimeZone(); 0075 0076 static void Wait(int milliseconds); 0077 0078 static void Wait4Midnight(); 0079 0080 XrdSysTimer() {Reset();} 0081 0082 private: 0083 struct timeval StopWatch; // Current running clock 0084 struct timeval LastReport; // Total time from last report 0085 0086 unsigned long Report(); // Place interval in Last Report 0087 }; 0088 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |