ewmscp  ..
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
timer::instanceUnscoped Class Reference

#include <timer.h>

Inheritance diagram for timer::instanceUnscoped:
[legend]
Collaboration diagram for timer::instanceUnscoped:
[legend]

Public Member Functions

 instanceUnscoped (anchor &aAnchor)
 
void stop ()
 
template<class T >
void stop (clock_type::duration timeout, const T &object)
 
void restart ()
 

Static Public Member Functions

static void updateMax (std::atomic< std::int64_t > &max, std::int64_t val)
 
static const std::string & stringy (const std::string &s)
 
static const std::string stringy (const std::vector< char > &s)
 

Private Attributes

anchorlAnchor
 
clock_type::time_point start
 

Detailed Description

Definition at line 95 of file timer.h.

Constructor & Destructor Documentation

◆ instanceUnscoped()

timer::instanceUnscoped::instanceUnscoped ( anchor aAnchor)
inline

Definition at line 99 of file timer.h.

99  : lAnchor(aAnchor) {
100  start = clock_type::now();
101  }

References start.

Member Function Documentation

◆ restart()

void timer::instanceUnscoped::restart ( )
inline

Definition at line 133 of file timer.h.

133  {
134  start = clock_type::now();
135  }

References start.

Referenced by inputHandler::posixFile::PosixDirectory::getNextEntry(), handleDir(), and runnerType::process().

Here is the caller graph for this function:

◆ stop() [1/2]

void timer::instanceUnscoped::stop ( )
inline

Definition at line 107 of file timer.h.

107  {
108  lAnchor.counter++;
109  auto timeSpent = clock_type::now() - start;
110  auto timeSpentNs = std::chrono::duration_cast<std::chrono::nanoseconds>(timeSpent).count();
111  lAnchor.timeSpent += timeSpentNs;
112  updateMax(lAnchor.maxTimeSpent, timeSpentNs);
113  }

References timer::anchor::counter, lAnchor, timer::anchor::maxTimeSpent, start, timer::anchor::timeSpent, and updateMax().

Referenced by outputHandler::libssh::writerLibssh::closeAndRemoveBadCopy(), outputHandler::libssh::ensureParentDirs(), outputHandler::posixFile::ensureParentDirs(), outputHandler::daosFs::ensureParentDirs(), daosFsIoCommon::attrDataType::fill(), inputHandler::posixFile::PosixDirectory::getNextEntry(), handleDir(), runnerType::process(), outputHandler::Gpfs::rename(), outputHandler::posixFile::rename(), outputHandler::daosFs::rename(), outputHandler::posixFile::writerPosixFile::writeBlock(), outputHandler::daosFs::writerDaosFs::writeBlock(), outputHandler::libssh::writerLibssh::writerLibssh(), timer::instance::~instance(), and timer::instanceWithTimeout< T >::~instanceWithTimeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop() [2/2]

template<class T >
void timer::instanceUnscoped::stop ( clock_type::duration  timeout,
const T &  object 
)
inline

Definition at line 121 of file timer.h.

121  {
122  lAnchor.counter++;
123  auto timeSpent = clock_type::now() - start;
124  auto timeSpentNs = std::chrono::duration_cast<std::chrono::nanoseconds>(timeSpent).count();
125  lAnchor.timeSpent += timeSpentNs;
126  updateMax(lAnchor.maxTimeSpent, timeSpentNs);
127  if (timeSpent > timeout) {
128  const std::string& oref(stringy(object));
130  oref, lAnchor.subfunc, "tardy action took ", std::chrono::duration_cast<std::chrono::duration<double>>(timeSpent).count(), "s");
131  }
132  }

References timer::anchor::counter, errMsg::debug, errMsg::emit(), timer::anchor::file, timer::anchor::function, lAnchor, timer::anchor::line, timer::anchor::maxTimeSpent, start, stringy(), timer::anchor::subfunc, timer::anchor::timeSpent, and updateMax().

Here is the call graph for this function:

◆ stringy() [1/2]

static const std::string& timer::instanceUnscoped::stringy ( const std::string &  s)
inlinestatic

Definition at line 114 of file timer.h.

114  {
115  return s;
116  }

Referenced by stop().

Here is the caller graph for this function:

◆ stringy() [2/2]

static const std::string timer::instanceUnscoped::stringy ( const std::vector< char > &  s)
inlinestatic

Definition at line 117 of file timer.h.

117  {
118  return std::string(s.data());
119  }

◆ updateMax()

static void timer::instanceUnscoped::updateMax ( std::atomic< std::int64_t > &  max,
std::int64_t  val 
)
inlinestatic

Definition at line 102 of file timer.h.

102  {
103  auto oldMax = max.load();
104  while (val > oldMax &&
105  !max.compare_exchange_weak(oldMax, val));
106  }

Referenced by stop().

Here is the caller graph for this function:

Member Data Documentation

◆ lAnchor

anchor& timer::instanceUnscoped::lAnchor
private

Definition at line 96 of file timer.h.

Referenced by stop().

◆ start

clock_type::time_point timer::instanceUnscoped::start
private

Definition at line 97 of file timer.h.

Referenced by instanceUnscoped(), restart(), and stop().


The documentation for this class was generated from the following file:
timer::instanceUnscoped::updateMax
static void updateMax(std::atomic< std::int64_t > &max, std::int64_t val)
Definition: timer.h:102
errMsg::location
class for defining the location of a error message in the source code.
Definition: errMsgQueue.h:14
timer::instanceUnscoped::lAnchor
anchor & lAnchor
Definition: timer.h:96
timer::anchor::file
const char * file
Definition: timer.h:27
timer::anchor::line
int line
Definition: timer.h:28
errMsg::level::debug
@ debug
timer::instanceUnscoped::stringy
static const std::string & stringy(const std::string &s)
Definition: timer.h:114
timer::anchor::counter
std::atomic< int > counter
Definition: timer.h:45
timer::anchor::timeSpent
std::atomic< std::uint64_t > timeSpent
Definition: timer.h:46
errMsg::emit
void emit(level aLogLevel, const location &loc, const std::string &aObject, const std::string &aAction, const Args &... args)
function to create and enqueue a message, this is the only way that messages should be created!
Definition: errMsgQueue.h:148
timer::anchor::subfunc
const char * subfunc
Definition: timer.h:25
timer::instanceUnscoped::start
clock_type::time_point start
Definition: timer.h:97
timer::anchor::function
const char * function
Definition: timer.h:26
timer::anchor::maxTimeSpent
std::atomic< std::int64_t > maxTimeSpent
Definition: timer.h:47