Add function to send signals to threads
This commit is contained in:
parent
635cbc24e7
commit
127aadbffc
2 changed files with 16 additions and 0 deletions
|
|
@ -131,6 +131,11 @@ namespace fc {
|
|||
* @todo make quit non-blocking of the calling thread by eliminating the call to <code>boost::thread::join</code>
|
||||
*/
|
||||
void quit();
|
||||
|
||||
/**
|
||||
* Send signal to underlying native thread. Only for Linux and macOS
|
||||
*/
|
||||
void signal(int);
|
||||
|
||||
/**
|
||||
* @return true unless quit() has been called.
|
||||
|
|
|
|||
|
|
@ -156,6 +156,17 @@ namespace fc {
|
|||
|
||||
void thread::debug( const fc::string& d ) { /*my->debug(d);*/ }
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
void thread::signal(int sig)
|
||||
{
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
pthread_kill( my->boost_thread->native_handle(), sig );
|
||||
#endif
|
||||
}
|
||||
|
||||
void thread::quit()
|
||||
{
|
||||
//if quitting from a different thread, start quit task on thread.
|
||||
|
|
|
|||
Loading…
Reference in a new issue