20 #include <boost/noncopyable.hpp> 21 #include <boost/scoped_ptr.hpp> 25 using std::unique_ptr;
26 using boost::scoped_ptr;
35 class Blocker : boost::noncopyable {
40 sigfillset(&new_mask);
41 pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask_);
46 pthread_sigmask(SIG_SETMASK, &old_mask_, 0);
77 bool should_delete(
false);
80 if (--
impl->waiting_ == 0) {
89 static void*
run(
void* impl_raw) {
90 Impl*
impl = static_cast<Impl*>(impl_raw);
93 }
catch (
const exception& e) {
94 impl->exception_ =
true;
95 impl->exception_text_ = e.what();
97 impl->exception_ =
true;
98 impl->exception_text_ =
"Unknown exception";
130 const int result = pthread_create(&
impl->tid_, NULL, &
Impl::run,
135 impl_ =
impl.release();
138 throw std::bad_alloc();
147 const int result = pthread_detach(impl_->
tid_);
159 "Wait called and no thread to wait for");
162 const int result = pthread_join(impl_->
tid_, NULL);
168 scoped_ptr<UncaughtException> ex;
187 if (ex.get() != NULL) {
Impl(const boost::function< void()> &main)
static void done(Impl *impl)
int main(int argc, char *argv[])
This holds a lock on a Mutex.
boost::function< void()> main_
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void wait()
Wait for the thread to terminate.
Thread(const boost::function< void()> &main)
Create and start a thread.
There's an uncaught exception in a thread.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Mutex with very simple interface.
A generic exception that is thrown if a function is called in a prohibited way.
static void * run(void *impl_raw)