20 setErrorInternal(
"no error");
25 sigaddset(&sset, SIGCHLD);
26 sigaddset(&sset, SIGINT);
27 sigaddset(&sset, SIGHUP);
28 sigaddset(&sset, SIGTERM);
29 pthread_sigmask(SIG_BLOCK, &sset, &osset);
31 thread_.reset(
new std::thread(thread_main));
34 pthread_sigmask(SIG_SETMASK, &osset, 0);
38 pthread_sigmask(SIG_SETMASK, &osset, 0);
43 return(sockets_[watch_type].getSelectFd());
53 return (sockets_[watch_type].
isReady());
81 setErrorInternal(
"thread stopped");
85 WatchedThread::setErrorInternal(
const std::string& error_msg) {
86 std::lock_guard<std::mutex> lock(mutex_);
87 last_error_ = error_msg;
92 setErrorInternal(error_msg);
98 std::lock_guard<std::mutex> lock(mutex_);
std::string getLastError()
Fetches the error message text for the most recent error.
void stop()
Terminates the thread.
int getWatchFd(WatchType watch_type)
Fetches the fd of a watch socket.
void clearReady()
Clears the socket's ready to read marker.
bool shouldTerminate()
Checks if the thread should terminate.
void start(const std::function< void()> &thread_main)
Creates and runs the thread.
bool isReady(WatchType watch_type)
Indicates if a watch socket state is ready.
void setError(const std::string &error_msg)
Sets the error state.
WatchType
Enumerates the list of watch sockets used to mark events These are used as arguments to watch socket ...
void markReady()
Marks the select-fd as ready to read.
Defines the logger used by the top-level component of kea-dhcp-ddns.
void clearReady(WatchType watch_type)
Sets a watch socket state to not ready.
void markReady(WatchType watch_type)
Sets a watch socket state to ready.