Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Using an aspect for a reentrant lock

With Java 5's inclusion of util.concurrent, locks are hot; this sample from the ReentrantLock javadoc begs for an aspect:

  public void m() { 
    lock.lock();  // block until condition holds
    try {
      // ... method body
    } finally {
      lock.unlock()
    }
  }

But then someone's already suggested as much:

  before() : writeOperations() {
    rwl.writeLock().acquire();//??advice body
  }

  after() : writeOperations() {
    rwl.writeLock().release(); //?? advice body
  }

  http://blog.csdn.net/duoshanx/archive/2004/12/30/234815.aspx

(Unfortunately, machine translation from japanese produces stuff like "Elephant? The demand number of militarys officer")

Enjoy -
Wes




Back to the top