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:
2022-11-05 23:43:07 +03:00
parent e48d0ebaab
commit 8a5e72c723
15 changed files with 498 additions and 209 deletions

View File

@@ -41,7 +41,7 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
PICloudServer::~PICloudServer() {
stop();
stopAndWait();
close();
}
@@ -107,6 +107,11 @@ void PICloudServer::stopThreadedReadDevice() {
}
void PICloudServer::interrupt() {
eth.interrupt();
}
void PICloudServer::clientDisconnect(uint client_id) {
tcp.sendDisconnected(client_id);
}
@@ -170,6 +175,11 @@ ssize_t PICloudServer::Client::writeDevice(const void * data, ssize_t size) {
}
void PICloudServer::Client::interrupt() {
cond_buff.notifyOne();
}
void PICloudServer::Client::pushBuffer(const PIByteArray & ba) {
if (!is_connected) return;
mutex_buff.lock();