Skip to content

Commit

Permalink
Revert "Added LockManager.performLocked with Runnable"
Browse files Browse the repository at this point in the history
This reverts commit 1b9dcd8.
  • Loading branch information
gastaldi committed Mar 19, 2013
1 parent 55638c9 commit 1d01656
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ public interface LockManager
* the result, if any.
*/
<T> T performLocked(LockMode mode, Callable<T> task);

/**
* Perform the given {@link Runnable} task after acquiring a {@link Lock} of the given {@link LockMode} type.
*/
void performLocked(LockMode mode, Runnable runnable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,4 @@ public <T> T performLocked(LockMode mode, Callable<T> task)
return result;
}

@Override
public void performLocked(LockMode mode, Runnable task)
{
Assert.notNull(mode, "LockMode must not be null.");
Assert.notNull(task, "Task to perform must not be null.");

Lock lock = obtainLock(mode);
lock.lock();
try
{
task.run();
}
catch (Exception e)
{
throw new ContainerException(e);
}
finally
{
lock.unlock();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package org.jboss.forge.container.addons;

import java.util.concurrent.Callable;

import org.jboss.forge.container.lock.LockManager;
import org.jboss.forge.container.lock.LockMode;
import org.jboss.forge.container.util.Assert;
Expand Down Expand Up @@ -57,12 +59,13 @@ public Addon getDependency()

public void setDependency(final Addon dependency)
{
lockManager.performLocked(LockMode.WRITE, new Runnable()
lockManager.performLocked(LockMode.WRITE, new Callable<Object>()
{
@Override
public void run()
public Object call() throws Exception
{
AddonDependencyImpl.this.dependency = dependency;
return dependency;
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ public Boolean call() throws Exception

public void removeServices(final ClassLoader classLoader) throws IllegalArgumentException
{
lock.performLocked(LockMode.WRITE, new Runnable()
lock.performLocked(LockMode.WRITE, new Callable<Void>()
{

@Override
public void run()
public Void call() throws Exception
{
Iterator<AddonImpl> it = addons.iterator();
while (it.hasNext())
Expand All @@ -154,6 +153,7 @@ public void run()
it.remove();
}
}
return null;
}
});
}
Expand Down

0 comments on commit 1d01656

Please sign in to comment.