Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-351

LockContainer.acquireLock() to return Lock instead of boolean?

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 4.0.0.Final
    • 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?

              rh-ee-galder Galder ZamarreƱo
              rh-ee-galder Galder ZamarreƱo
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: