Hey Jules -
I’ve been employing value objects a lot lately, and finally started to run up against a few errors that I don’t quite understand.
Since Value objects are not thread safe, I’ve got a subclass that has a CriticalSection which gets locked before any getValue or setValue operations. I had thought this would be enough to get them to be fully threadsafe, but I’m starting to realize this may not be the case.
The objects are fine nearly all the time, but there are some issues that arise because the Message Manager thread sometimes accesses the Value objects (I think).
So for example … If I am understanding correctly …
Here is an issue where two threads both try to access the object: on one, a midi message has come in that is mapped to some value object, so it has locked the CriticalSection and altered the value. It is now trying to send a message.
The other thread (the MM) is going through it’s messages, has found one related to this ValueObject and is calling all the listeners.
Anyway, you can see the issue. My question, really, is whether it is feasible to use Value objects in a multithreaded environment at all? or if I should write some custom shared var objects that lock more often.