migrate to async IO model
new PIIODevice::interrupt() virtual method new PIWaitEvent private class PIEthernet and PISerial basically tested on Windows and Linux
This commit is contained in:
@@ -131,8 +131,8 @@ PIIODevice::PIIODevice(const PIString & path, PIIODevice::DeviceMode mode): PIOb
|
||||
|
||||
|
||||
PIIODevice::~PIIODevice() {
|
||||
stop();
|
||||
waitThreadedReadFinished();
|
||||
destroying = true;
|
||||
stopAndWait();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,8 +215,10 @@ void PIIODevice::stopThreadedRead() {
|
||||
read_thread.stop();
|
||||
#else
|
||||
read_thread.stop();
|
||||
read_thread.interrupt();
|
||||
stopThreadedReadDevice();
|
||||
if (!destroying) {
|
||||
interrupt();
|
||||
stopThreadedReadDevice();
|
||||
}
|
||||
if (reading_now) {
|
||||
read_thread.terminate();
|
||||
reading_now = false;
|
||||
@@ -271,6 +273,13 @@ void PIIODevice::stop() {
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::stopAndWait(int timeout_ms) {
|
||||
stop();
|
||||
waitThreadedReadFinished(timeout_ms);
|
||||
waitThreadedWriteFinished(timeout_ms);
|
||||
}
|
||||
|
||||
|
||||
ssize_t PIIODevice::read(void * read_to, ssize_t max_size) {
|
||||
ssize_t ret = readDevice(read_to, max_size);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user