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");
85WatchedThread::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_);
void clearReady()
Clears the socket's ready to read marker.
void markReady()
Marks the select-fd as ready to read.
void start(const std::function< void()> &thread_main)
Creates and runs the thread.
int getWatchFd(WatchType watch_type)
Fetches the fd of a watch socket.
bool shouldTerminate()
Checks if the thread should terminate.
void markReady(WatchType watch_type)
Sets a watch socket state to ready.
bool isReady(WatchType watch_type)
Indicates if a watch socket state is ready.
std::string getLastError()
Fetches the error message text for the most recent error.
void clearReady(WatchType watch_type)
Sets a watch socket state to not ready.
WatchType
Enumerates the list of watch sockets used to mark events These are used as arguments to watch socket ...
void stop()
Terminates the thread.
void setError(const std::string &error_msg)
Sets the error state.
Defines the logger used by the top-level component of kea-lfc.