-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
-
None
I'm finding LockContainer and its implementations such as ReentrantPerEntryLockContainer very useful in other projects for example when you wanna maintain some kind of per-key locks.
However, discussing with Brian, he made a good point about the LockContainer API:
boolean acquireLock(Object key, long timeout, TimeUnit unit) throws InterruptedException;
Lock getLock(Object key);
Sometimes, you wanna acquire the lock and keep the lock around. To do so right now, u have to make two calls, one to acquireLock and one to getLock. It'd be better if acquireLock was enhanced to be this way:
Lock acquireLock(Object key, long timeout, TimeUnit unit) throws InterruptedException;
So, if acquireLock suceeds, it returns the lock immediately. If it doesn't, it could simply return null.
WDYT?