Open LK-Simon opened 6 years ago
Only downside with this approach is that some Classes may define multiple Read/Write locks with the CURRENT solution. However, this should be seen as an architectural mistake, as associated values governed by a distinct Lock should be encapsulated in a distinct Class.
There is a possible performance issue with a Universal Mutex solution, in that a lookup would take place to determine whether or not a Mutex already exists for a given Object Instance.
If that performance hit is significant, it would still be worthwhile implementing the solution so that any non-ADAPT Object Instances can benefit from a Universal Mutex, while still providing the inherited Threadsafe counterparts for all of the ADAPT Class Types as presently implemented.
At the moment, the ADAPT library provides non-Threadsafe and Inherited Threadsafe counterparts for all rational Classes.
This is okay, but involves a significant amount of code replication.
What would be useful is a means of encapsulating an object in a Universal Read/Write Mutex, which then provides the Acquire/Release methods for both Read and Write locking, and only returns the object over which the lock applies when that lock is available.
This means we only have one implementation of our Universal Read/Write Mutex Class, only one implementation (inherently non-Threadsafe) of our various Classes, but can impose a Read/Write Mutex Lock on ANY Object.
I'm not 100% on the best way to implement this solution, but I will explore it, and if it's viable, this will become the defacto solution.