Merge branch 'master' into pico_sdk
This commit is contained in:
@@ -574,6 +574,8 @@ bool PIConnection::removeFilter(const PIString & name_) {
|
||||
|
||||
|
||||
void PIConnection::removeAllFilters() {
|
||||
PIVector<Extractor *> to_delete;
|
||||
PIVector<PIDiagnostics *> diags_to_delete;
|
||||
__device_pool__->lock();
|
||||
for (auto i = extractors.begin(); i != extractors.end(); i++) {
|
||||
if (!i.value()) continue;
|
||||
@@ -583,14 +585,18 @@ void PIConnection::removeAllFilters() {
|
||||
it.value().removeAll(i.value()->extractor);
|
||||
}
|
||||
if (diags_.value(i.value()->extractor)) {
|
||||
delete diags_.value(i.value()->extractor);
|
||||
diags_to_delete << diags_.value(i.value()->extractor);
|
||||
diags_.remove(i.value()->extractor);
|
||||
}
|
||||
diags_.remove(i.value()->extractor);
|
||||
delete i.value();
|
||||
to_delete << i.value();
|
||||
}
|
||||
extractors.clear();
|
||||
bounded_extractors.clear();
|
||||
__device_pool__->unlock();
|
||||
for (auto e: to_delete)
|
||||
delete e;
|
||||
for (auto d: diags_to_delete)
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
@@ -996,6 +1002,7 @@ PIIODevice * PIConnection::DevicePool::addDevice(PIConnection * parent, const PI
|
||||
if (pmode == mode || pmode == PIIODevice::ReadWrite) return dd->dev;
|
||||
if ((mode & PIIODevice::ReadOnly) > 0) {
|
||||
if (dd->rthread) {
|
||||
dd->rthread->stopAndWait();
|
||||
delete dd->rthread;
|
||||
dd->rthread = nullptr;
|
||||
dd->started = false;
|
||||
@@ -1135,10 +1142,13 @@ PIConnection::DevicePool::DeviceData::~DeviceData() {
|
||||
void PIConnection::DevicePool::run() {
|
||||
PIVector<PIConnection *> conns(PIConnection::allConnections());
|
||||
for (PIConnection * c: conns) {
|
||||
if (!c) continue;
|
||||
__device_pool__->lock();
|
||||
for (auto d = c->diags_.begin(); d != c->diags_.end(); d++) {
|
||||
if (!d.value()) continue;
|
||||
d.value()->tick(1);
|
||||
}
|
||||
__device_pool__->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,9 +1239,14 @@ void PIConnection::Sender::tick(int) {
|
||||
if (data.isEmpty()) return;
|
||||
// piCoutObj << "write"<<data.size()<<"bytes to"<<devices.size()<<"devices";
|
||||
for (PIIODevice * d: devices) {
|
||||
int ret = d->write(data);
|
||||
PIDiagnostics * diag = parent->diags_.value(d, nullptr);
|
||||
if (diag && ret > 0) diag->sended(ret);
|
||||
int ret = d->write(data);
|
||||
if (ret > 0) {
|
||||
PIDiagnostics * diag = nullptr;
|
||||
__device_pool__->lock();
|
||||
diag = parent->diags_.value(d, nullptr);
|
||||
__device_pool__->unlock();
|
||||
if (diag) diag->sended(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user