Deltares / Deltares/ProbabilisticLibrary
improve locking in project handler
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8
- Forks
- 1
- Avg merge
- 4d 18h
- Merged PRs (30d)
- 4
Description
Task description
for the dot net interface locks are added as the garbage collector calls the destroy method from another thread.
with the changes in PR #342 the number of locks are way too many. But setting the lock on a higher level will set the lock more times and is often not necessary.
There are a few ways to solve this:
- do not allow calling the project handler from different threads ; then the dot net wrapper has to handle it
- move the locks to another location in the project handler ; see PR #342 for that location.
- make the locking optional, then calling it too often only influences applications that actually need this locking.
- use Concurrent Containers from Boost, see: https://www.boost.org/doc/libs/latest/libs/unordered/doc/html/unordered/concurrent.html
- split up projectHandler.cpp and make a class for each type, e.g. StochastHandler, HistogramValueHandler, etc.. These classes have functionality in common, such as the code where the lock is required, which will be programmed only once. These classes are templated and all derive from a base class.
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing projectHandler.cpp and PR #342 to understand where the current locks were added for the .NET interface and garbage-collector destroy calls. Compare the listed approaches and establish one locking strategy that preserves cross-thread safety without excessive locking; done means the chosen design is implemented and its thread-safety tradeoffs are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100