Skip to content
Snippets Groups Projects
Commit 2967784c authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

Workaround for the svr_writer thread (of DOOCS) to block location mutexes for...

Workaround for the svr_writer thread (of DOOCS) to block location mutexes for a very long time if many big D_spectrum are written. The write is now only done if necessary (i.e. after a modification) and the lock is released for a short period of time to make sure RPC calls don't get blocked for too long.
parent 0d8aa5ba
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,8 @@ namespace ChimeraTK {
void setMacroPulseNumberSource(boost::shared_ptr<ChimeraTK::NDRegisterAccessor<int64_t>> macroPulseNumberSource);
void write(fstream& fptr) override;
boost::shared_ptr<ChimeraTK::NDRegisterAccessor<float>> _processArray;
boost::shared_ptr<ChimeraTK::NDRegisterAccessor<float>> _startAccessor;
boost::shared_ptr<ChimeraTK::NDRegisterAccessor<float>> _incrementAccessor;
......@@ -85,6 +87,9 @@ namespace ChimeraTK {
// the ChimeraTK ProcessArray and calls the send method. Factored out to allow
// unit testing.
void sendToDevice();
// Flag whether the value has been modified since the content has been saved to disk the last time (see write()).
bool modified{false};
};
} // namespace ChimeraTK
......
......@@ -57,6 +57,7 @@ namespace ChimeraTK {
void DoocsSpectrum::set(EqAdr* eqAdr, EqData* data1, EqData* data2, EqFct* eqFct) {
D_spectrum::set(eqAdr, data1, data2, eqFct);
modified = true;
sendToDevice();
}
......@@ -71,11 +72,24 @@ namespace ChimeraTK {
// send the current value to the device
D_spectrum::read();
modified = false;
if(_processArray->isWriteable()) {
sendToDevice();
}
}
void DoocsSpectrum::write(fstream& fptr) {
// DOOCS is normally keeping the location lock until everything is written for that location: all D_spectrum and all
// other properties. This can take too long (like seconds), which leads to noticable freezes of the UI. As a
// work-around we release the lock here, wait some time and acquire the lock again. Since this happens in a separate
// thread (svr_writer), this slow-down should not be of any harm.
efp_->unlock();
usleep(1000);
efp_->lock();
if(!modified) return;
D_spectrum::write(fptr);
}
void DoocsSpectrum::updateDoocsBuffer(TransferElementID transferElementId) {
// Note: we already own the location lock by specification of the DoocsUpdater
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment