xrootd
Loading...
Searching...
No Matches
XrdSysTimer.hh
Go to the documentation of this file.
1#ifndef __XrdSysTimer__
2#define __XrdSysTimer__
3/******************************************************************************/
4/* */
5/* X r d S y s T i m e r . h h */
6/* */
7/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#ifndef WIN32
33#include <sys/time.h>
34#else
35#include <ctime>
36#include <Winsock2.h>
37#include "XrdSys/XrdWin32.hh"
38#endif
39
40/* This include file describes the oo elapsed time interval interface. It is
41 used by the oo Real Time Monitor, among others.
42*/
43
45
46public:
47 struct timeval *Delta_Time(struct timeval &tbeg);
48
49static time_t Midnight(time_t tnow=0);
50
51inline int TimeLE(time_t tsec) {return StopWatch.tv_sec <= tsec;}
52
53 // The following routines return the current interval added to the
54 // passed argument as well as returning the current Unix seconds
55 //
56 unsigned long Report(double &);
57 unsigned long Report(unsigned long &);
58 unsigned long Report(unsigned long long &);
59 unsigned long Report(struct timeval &);
60
61inline void Reset() {gettimeofday(&StopWatch, 0);}
62
63inline time_t Seconds() {return StopWatch.tv_sec;}
64
65inline void Set(struct timeval &tod)
66 {StopWatch.tv_sec = tod.tv_sec;
67 StopWatch.tv_usec = tod.tv_usec;
68 }
69
70static void Snooze(int seconds);
71
72static char *s2hms(int sec, char *buff, int blen);
73
74static int TimeZone();
75
76static void Wait(int milliseconds);
77
78static void Wait4Midnight();
79
81
82private:
83 struct timeval StopWatch; // Current running clock
84 struct timeval LastReport; // Total time from last report
85
86 unsigned long Report(); // Place interval in Last Report
87};
88#endif
Definition XrdSysTimer.hh:44
static void Wait(int milliseconds)
unsigned long Report(unsigned long long &)
static void Snooze(int seconds)
void Reset()
Definition XrdSysTimer.hh:61
static char * s2hms(int sec, char *buff, int blen)
struct timeval LastReport
Definition XrdSysTimer.hh:84
unsigned long Report(struct timeval &)
int TimeLE(time_t tsec)
Definition XrdSysTimer.hh:51
struct timeval * Delta_Time(struct timeval &tbeg)
time_t Seconds()
Definition XrdSysTimer.hh:63
struct timeval StopWatch
Definition XrdSysTimer.hh:83
void Set(struct timeval &tod)
Definition XrdSysTimer.hh:65
unsigned long Report(double &)
XrdSysTimer()
Definition XrdSysTimer.hh:80
unsigned long Report(unsigned long &)
static time_t Midnight(time_t tnow=0)
static void Wait4Midnight()
unsigned long Report()
static int TimeZone()