Electroneum
Loading...
Searching...
No Matches
tools::threadpool::waiter Class Reference

#include <threadpool.h>

Public Member Functions

void inc ()
void dec ()
void wait (threadpool *tpool)
 waiter ()
 Wait for a set of tasks to finish.
 ~waiter ()

Detailed Description

Definition at line 56 of file threadpool.h.

Constructor & Destructor Documentation

◆ waiter()

tools::threadpool::waiter::waiter ( )
inline

Wait for a set of tasks to finish.

Definition at line 64 of file threadpool.h.

64: num(0){}

◆ ~waiter()

tools::threadpool::waiter::~waiter ( )

Definition at line 96 of file threadpool.cpp.

97{
98 try
99 {
100 boost::unique_lock<boost::mutex> lock(mt);
101 if (num)
102 MERROR("wait should have been called before waiter dtor - waiting now");
103 }
104 catch (...) { /* ignore */ }
105 try
106 {
107 wait(NULL);
108 }
109 catch (const std::exception &e)
110 {
111 /* ignored */
112 }
113}
void wait(threadpool *tpool)
#define MERROR(x)
Definition misc_log_ex.h:73
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ dec()

void tools::threadpool::waiter::dec ( )

Definition at line 128 of file threadpool.cpp.

128 {
129 const boost::unique_lock<boost::mutex> lock(mt);
130 num--;
131 if (!num)
132 cv.notify_all();
133}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inc()

void tools::threadpool::waiter::inc ( )

Definition at line 123 of file threadpool.cpp.

123 {
124 const boost::unique_lock<boost::mutex> lock(mt);
125 num++;
126}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait()

void tools::threadpool::waiter::wait ( threadpool * tpool)

Definition at line 115 of file threadpool.cpp.

115 {
116 if (tpool)
117 tpool->run(true);
118 boost::unique_lock<boost::mutex> lock(mt);
119 while(num)
120 cv.wait(lock);
121}
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/threadpool.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/threadpool.cpp