Scroom 0.14-49-gb7ae7a6d
Loading...
Searching...
No Matches
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
44 : name(std::move(name_))
45{
46}
std::string name
Definition measure-load-performance-tests.cc:27

◆ WaitForAsyncOp() [2/3]

WaitForAsyncOp::WaitForAsyncOp ( const WaitForAsyncOp other)
49 : name(other.name)
50 , started(other.started)
51 , t(other.t)
52{
53}
bool started
Definition measure-load-performance-tests.cc:29
struct timespec t
Definition measure-load-performance-tests.cc:30

◆ WaitForAsyncOp() [3/3]

WaitForAsyncOp::WaitForAsyncOp ( WaitForAsyncOp &&  other)
56 : name(std::move(other.name))
57 , started(std::move(other.started))
58 , t(std::move(other.t))
59{
60}

◆ ~WaitForAsyncOp()

WaitForAsyncOp::~WaitForAsyncOp ( )
default

Member Function Documentation

◆ operator()()

bool WaitForAsyncOp::operator() ( )
63{
64 if(!started && 0 == clock_gettime(CLOCK_REALTIME, &t))
65 {
66 started = true;
67
68 Sequentially()->schedule([&s = this->s] { s.V(); });
69
70 std::cout << "Waiting for " << name << std::endl;
71 return true;
72 }
73
74 s.P();
75 struct timespec now = {0, 0};
76 if(0 == clock_gettime(CLOCK_REALTIME, &now))
77 {
78 const double duration = now.tv_sec - t.tv_sec + (now.tv_nsec - t.tv_nsec) / 1E9;
79
80 std::cout << name << " took " << duration << "s" << std::endl;
81 }
82 return false;
83}
void P()
Definition semaphore.hh:38
void V()
Definition semaphore.hh:77
Scroom::Semaphore s
Definition measure-load-performance-tests.cc:28
ThreadPool::Ptr Sequentially()
Definition threadpoolimpl.cc:462
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
29{false};

Referenced by operator()().

◆ t

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

Referenced by operator()().


The documentation for this class was generated from the following file: