You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
falk-werner_webfuse/test-src/webfuse/test/thread.cpp

39 lines
563 B

#include "webfuse/test/thread.hpp"
#include <csignal>
namespace
{
extern "C" void * webfuse_thread_main(void * args)
{
auto * run = reinterpret_cast<std::function<void(void)> *>(args);
(*run)();
return nullptr;
}
}
namespace webfuse
{
thread::thread(std::function<void(void)> run)
{
pthread_create(&real_thread, nullptr,
&webfuse_thread_main,
reinterpret_cast<void*>(&run));
}
thread::~thread()
{
pthread_join(real_thread, nullptr);
}
void thread::kill(int signal_id)
{
pthread_kill(real_thread, signal_id);
}
}