Consolidate thread lock/data race handling #277
Labels
bug
Something isn't working
documentation
Improvements or additions to documentation
enhancement
New feature or request
performance
I've noticed a number of competing techniques used to manage data races throughout the codebase.
There is the RT_LOCK (I assume RT = runtime) used to manage global state access and modifications. However, it's not immediately clear which objects require this RT_LOCK, and its use is enforced only by code review.
In a few other places I've also noticed use of atomics to handle these cases, for example in the Queue objects during deletion.
I would like to suggest standardising on how we handle this to ensure correctness and simplicity of design. It makes code brittle if their are competing paradigms for handling data race conditions.
I'm not an expert in how to handle this kind of thing, and I'm sure there are various options but I'd like to propose to couple any shared state object with its lock, e.g. something like:
and accesses to this object can happen via a pattern such as:
where
lock()
is simply something like:The benefits here mean its obvious which objects require locking before use, and any collection of objects which require synchronisation can share a lock between them.
My 2 cents. But I think it's a discussion that needs to happen.
The text was updated successfully, but these errors were encountered: