X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=thread.h;h=46b6d3952ff0cb262d24c077993d18b308ad3e9c;hp=12aa133d82f77781e6de0b3273e8dc0128232d76;hb=1d285bcbfd1aa3f7911cfb98a947a37f68154428;hpb=3fd8650ccf3da3960a946d8ac9abc305aec399ce diff --git a/thread.h b/thread.h index 12aa133..46b6d39 100644 --- a/thread.h +++ b/thread.h @@ -4,6 +4,8 @@ #include #include +#include + struct timespec; // A thread class with start/stop and signal functionality. @@ -32,13 +34,14 @@ protected: // the file descriptor. // // If fd is -1, wait until a wakeup or timeout. - // if timeout_ts is NULL, there is no timeout. + // if timeout_ts is nullptr, there is no timeout. bool wait_for_activity(int fd, short events, const timespec *timeout_ts); // Wait until a wakeup. void wait_for_wakeup(const timespec *timeout_ts) { wait_for_activity(-1, 0, timeout_ts); } - // Make wait_for_activity() return. + // Make wait_for_activity() return. Note that this is a relatively expensive + // operation. void wakeup(); bool should_stop(); @@ -50,7 +53,7 @@ private: pthread_t worker_thread; // Protects should_stop_status. - pthread_mutex_t should_stop_mutex; + std::mutex should_stop_mutex; // If this is set, the thread should return as soon as possible from do_work(). bool should_stop_status;