Scroom  0.14
WaitForAsyncOp Class Reference
Collaboration diagram for WaitForAsyncOp:
Collaboration graph

Public Member Functions

 WaitForAsyncOp (std::string name)
 
 WaitForAsyncOp (const WaitForAsyncOp &other)
 
 WaitForAsyncOp (WaitForAsyncOp &&)
 
WaitForAsyncOp operator= (const WaitForAsyncOp &)=delete
 
WaitForAsyncOp operator= (WaitForAsyncOp &&)=delete
 
 ~WaitForAsyncOp ()=default
 
bool operator() ()
 

Private Attributes

std::string name
 
Scroom::Semaphore s
 
bool started {false}
 
struct timespec t = {0, 0}
 

Constructor & Destructor Documentation

◆ WaitForAsyncOp() [1/3]

WaitForAsyncOp::WaitForAsyncOp ( std::string  name)
explicit
48  : name(std::move(name_))
49 {
50 }

◆ WaitForAsyncOp() [2/3]

WaitForAsyncOp::WaitForAsyncOp ( const WaitForAsyncOp other)
53  : name(other.name)
54  , started(other.started)
55  , t(other.t)
56 {
57 }

◆ WaitForAsyncOp() [3/3]

WaitForAsyncOp::WaitForAsyncOp ( WaitForAsyncOp &&  other)
60  : name(std::move(other.name))
61  , started(std::move(other.started))
62  , t(std::move(other.t))
63 {
64 }

◆ ~WaitForAsyncOp()

WaitForAsyncOp::~WaitForAsyncOp ( )
default

Member Function Documentation

◆ operator()()

bool WaitForAsyncOp::operator() ( )
67 {
68  if(!started && 0 == clock_gettime(CLOCK_REALTIME, &t))
69  {
70  started = true;
71 
72  Sequentially()->schedule(boost::bind(clear, boost::ref(s)));
73 
74  std::cout << "Waiting for " << name << std::endl;
75  return true;
76  }
77 
78  s.P();
79  struct timespec now = {0, 0};
80  if(0 == clock_gettime(CLOCK_REALTIME, &now))
81  {
82  const double duration = now.tv_sec - t.tv_sec + (now.tv_nsec - t.tv_nsec) / 1E9;
83 
84  std::cout << name << " took " << duration << "s" << std::endl;
85  }
86  return false;
87 }
Here is the call graph for this function:

◆ operator=() [1/2]

WaitForAsyncOp WaitForAsyncOp::operator= ( const WaitForAsyncOp )
delete

◆ operator=() [2/2]

WaitForAsyncOp WaitForAsyncOp::operator= ( WaitForAsyncOp &&  )
delete

Member Data Documentation

◆ name

std::string WaitForAsyncOp::name
private

Referenced by operator()().

◆ s

Scroom::Semaphore WaitForAsyncOp::s
private

Referenced by operator()().

◆ started

bool WaitForAsyncOp::started {false}
private

Referenced by operator()().

◆ t

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

Referenced by operator()().


The documentation for this class was generated from the following file:
WaitForAsyncOp::started
bool started
Definition: measure-load-performance-tests.cc:33
WaitForAsyncOp::name
std::string name
Definition: measure-load-performance-tests.cc:31
Sequentially
ThreadPool::Ptr Sequentially()
Definition: threadpoolimpl.cc:459
Scroom::Semaphore::P
void P()
Definition: semaphore.hh:38
clear
static void clear(Scroom::Semaphore &s)
Definition: measure-load-performance-tests.cc:26
WaitForAsyncOp::s
Scroom::Semaphore s
Definition: measure-load-performance-tests.cc:32
WaitForAsyncOp::t
struct timespec t
Definition: measure-load-performance-tests.cc:34