--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "thread.h"
+
+void Thread::run()
+{
+ should_stop = false;
+ pthread_create(&worker_thread, NULL, &Thread::do_work_thunk, this);
+}
+
+void Thread::stop()
+{
+ should_stop = true;
+ pthread_kill(worker_thread, SIGHUP);
+ if (pthread_join(worker_thread, NULL) == -1) {
+ perror("pthread_join");
+ exit(1);
+ }
+}
+
+void *Thread::do_work_thunk(void *arg)
+{
+ Thread *thread = reinterpret_cast<Thread *>(arg);
+ thread->do_work();
+ return NULL;
+}
+