[concurrency-interest] Observability of Semaphore

Leon Chadwick leon@instagrade.com
Tue, 17 Jun 2003 23:21:32 +0100


Hello,
        I have been looking at the JSR166 specification API for java.util.concurrent and also your earlier (excellent by the way) release of the concurrency package.
I have a requirement that is partly fulfilled by the ObservableSync class, however I was concerned about whether this feature will be available in the java.util.concurrent package.

Basically, I am implementing a conditional tree where nodes in the tree have true/false values, and I need to support nodes whose value is derived from whether a lock style object has been acquired or not. (e.g. for a semaphore, have any of the permits been taken - note the semaphore allows me to get the current available permits but not the initial count of permits at construction, so I cannot even work this out using solely the semaphore object).


My specific application which will use this conditional tree allows a button on a gui to be enabled if and only if multiple conditions anded together evaluate to true, and one of these conditions is whether a lock has been obtained.
I want to use something like the observable pattern on my conditions so that when a condition changes the whole tree is re-evaluated, and in my application the button would become enabled if the conditions were met.

I know that I could have my application written using a style where all programming involving acquiring/releasing a lock also sets state on a condition object immediately before/after the acquire/release, however it would be a better design if I could make use of observability on the lock itself as then programming errors could be avoided.

Any thoughts you have on this subject would be much appreciated so I know which direction I should be working on for future compatability.

Regards

Leon Chadwick

Chief Technology Officer
Instagrade Limited