new PIClientServer::ClientBase::stopAndWait() method for blocking stop read.
PIClientServer::ClientBase::close() now non-blocking
This commit is contained in:
@@ -41,6 +41,7 @@ PIClientServer::Client::Client() {
|
||||
PIClientServer::Client::~Client() {
|
||||
if (tcp) tcp->setDebug(false);
|
||||
close();
|
||||
stopAndWait();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ PIClientServer::ClientBase::ClientBase() {}
|
||||
|
||||
PIClientServer::ClientBase::~ClientBase() {
|
||||
close();
|
||||
stopAndWait();
|
||||
if (own_tcp) piDeleteSafety(tcp);
|
||||
}
|
||||
|
||||
@@ -34,7 +35,13 @@ PIClientServer::ClientBase::~ClientBase() {
|
||||
void PIClientServer::ClientBase::close() {
|
||||
if (!tcp) return;
|
||||
can_write = false;
|
||||
tcp->interrupt();
|
||||
tcp->stop();
|
||||
stream.clear();
|
||||
}
|
||||
|
||||
|
||||
void PIClientServer::ClientBase::stopAndWait() {
|
||||
if (!tcp) return;
|
||||
tcp->stopAndWait(10_s);
|
||||
if (tcp->isThreadedRead()) tcp->terminateThreadedRead();
|
||||
tcp->close();
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
const PIEthernet * getTCP() const { return tcp; }
|
||||
|
||||
void close();
|
||||
void stopAndWait();
|
||||
|
||||
int write(const void * d, const size_t s);
|
||||
int write(const PIByteArray & ba) { return write(ba.data(), ba.size()); }
|
||||
|
||||
Reference in New Issue
Block a user