JeffersonLab / JANA2

Multi-threaded HENP Event Reconstruction
https://jeffersonlab.github.io/JANA2/
Other
6 stars 9 forks source link

Need lock_guard for JGlobalRootLock #125

Open faustus123 opened 2 years ago

faustus123 commented 2 years ago

It would be great to have the equivalent to a lock_guard for the JGlobalRootLock service. Probably need two, a read and a write. Could we implement something that would support something like:

auto lck = m_lock->LockGuardWrite();

DraTeots commented 2 years ago

BTW how JGlobalRootLock relates to ROOT EnableThreadSafety() which enables global lock also. Could it be moved on root? Or it is too uncontrollable?

P.S. A bit more on it from ROOT docs

faustus123 commented 2 years ago

I think the primary use case of modifying TTree and TH* objects will still require our own lock according to the documentation you point to. Those objects are considered "conditionally" thread safe, but since we are typically filling them from multiple threads, they will need to be synchronized.

nathanwbrei commented 2 years ago

C++ adds a read-write mutex/lock guard called std::shared_mutex/lock. The catch is that it is C++17, so I doubt it will work on gcc4.8.5.

DraTeots commented 2 years ago

And 4.8.5 is a requirement for Gluex/JLab? As EIC soft is on C++17