]> git.sesse.net Git - cubemap/blobdiff - thread.cpp
Use in-class initialization for making it harder to forget to set a default.
[cubemap] / thread.cpp
index 98c743c594313704281c2360f2d5688c0c691cab..473c71a82110821745ce176b8d4259c77375d66a 100644 (file)
@@ -1,6 +1,5 @@
 #include <assert.h>
 #include <errno.h>
-#include <fcntl.h>
 #include <poll.h>
 #include <signal.h>
 #include <stdio.h>
@@ -15,9 +14,9 @@ Thread::~Thread() {}
 
 void Thread::run()
 {
-       pthread_mutex_init(&should_stop_mutex, NULL);
+       pthread_mutex_init(&should_stop_mutex, nullptr);
        should_stop_status = false;
-       pthread_create(&worker_thread, NULL, &Thread::do_work_thunk, this);
+       pthread_create(&worker_thread, nullptr, &Thread::do_work_thunk, this);
 }
 
 void Thread::stop()
@@ -27,7 +26,7 @@ void Thread::stop()
                should_stop_status = true;
        }
        wakeup();
-       if (pthread_join(worker_thread, NULL) == -1) {
+       if (pthread_join(worker_thread, nullptr) == -1) {
                log_perror("pthread_join");
                exit(1);
        }
@@ -43,7 +42,7 @@ void *Thread::do_work_thunk(void *arg)
        sigset_t set;
        sigemptyset(&set);
        sigaddset(&set, SIGHUP);
-       int err = pthread_sigmask(SIG_BLOCK, &set, NULL);
+       int err = pthread_sigmask(SIG_BLOCK, &set, nullptr);
        if (err != 0) {
                errno = err;
                log_perror("pthread_sigmask");
@@ -62,7 +61,7 @@ void *Thread::do_work_thunk(void *arg)
 
        // Call the right thunk.
        thread->do_work();
-       return NULL;
+       return nullptr;
 }
 
 bool Thread::wait_for_activity(int fd, short events, const struct timespec *timeout_ts)