Scroom  0.14
Sleeper Class Reference

#include <test-helpers.hh>

Collaboration diagram for Sleeper:
Collaboration graph

Public Member Functions

 Sleeper (unsigned int secs)
 
bool operator() ()
 

Private Attributes

unsigned int secs
 
bool started {false}
 
struct timespec t = {0, 0}
 

Constructor & Destructor Documentation

◆ Sleeper()

Sleeper::Sleeper ( unsigned int  secs)
explicit
94  : secs(secs_)
95 {
96 }

Member Function Documentation

◆ operator()()

bool Sleeper::operator() ( )
99 {
100  if(!started && 0 == clock_gettime(CLOCK_REALTIME, &t))
101  {
102  started = true;
103  return true;
104  }
105 
106  struct timespec now = {0, 0};
107  if(0 == clock_gettime(CLOCK_REALTIME, &now))
108  {
109  if(now.tv_sec > t.tv_sec + secs)
110  {
111  return false;
112  }
113  }
114 
115  return true;
116 }

Member Data Documentation

◆ secs

unsigned int Sleeper::secs
private

Referenced by operator()().

◆ started

bool Sleeper::started {false}
private

Referenced by operator()().

◆ t

struct timespec Sleeper::t = {0, 0}
private

Referenced by operator()().


The documentation for this class was generated from the following files:
Sleeper::secs
unsigned int secs
Definition: test-helpers.hh:88
Sleeper::t
struct timespec t
Definition: test-helpers.hh:90
Sleeper::started
bool started
Definition: test-helpers.hh:89