start move to interruption of blocking calls, PIThread and PIEthernet
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
#ifndef MICRO_PIP
|
||||
# include "pisystemtests.h"
|
||||
#endif
|
||||
#ifdef WINDOWS
|
||||
# include <ioapiset.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#if defined(WINDOWS)
|
||||
# define __THREAD_FUNC_RET__ uint __stdcall
|
||||
@@ -591,6 +594,26 @@ PIThread::~PIThread() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
NTAPI void winThreadAPC(ULONG_PTR) {
|
||||
//piCout << "APC";
|
||||
}
|
||||
#endif
|
||||
|
||||
void PIThread::interrupt() {
|
||||
if (PRIVATE->thread == 0) return;
|
||||
piCout << "PIThread::interrupt";
|
||||
#ifdef WINDOWS
|
||||
CancelSynchronousIo(PRIVATE->thread);
|
||||
QueueUserAPC(winThreadAPC, PRIVATE->thread, 0);
|
||||
#else
|
||||
# ifdef POSIX_SIGNALS
|
||||
pthread_kill(PRIVATE->thread, SIGUSR2);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PIThread::stop(bool wait) {
|
||||
//PICout(PICoutManipulators::DefaultControls) << "thread" << this << "stop ..." << running_ << wait;
|
||||
terminating = true;
|
||||
|
||||
Reference in New Issue
Block a user