20#include <boost/noncopyable.hpp>
21#include <boost/scoped_ptr.hpp>
26using boost::scoped_ptr;
35class 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";
128 unique_ptr<Impl> impl(
new Impl(
main));
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) {
int main(int argc, char *argv[])
A generic exception that is thrown if a function is called in a prohibited way.
This holds a lock on a Mutex.
Mutex with very simple interface.
static void * run(void *impl_raw)
Impl(const boost::function< void()> &main)
boost::function< void()> main_
static void done(Impl *impl)
There's an uncaught exception in a thread.
void wait()
Wait for the thread to terminate.
Thread(const boost::function< void()> &main)
Create and start a thread.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Defines the logger used by the top-level component of kea-dhcp-ddns.