-
Notifications
You must be signed in to change notification settings - Fork 44
@Await @Signal @SignalBeforeAwaitAfter
peichhorn edited this page Jun 30, 2012
·
1 revision
(Documentation pending)
import lombok.AccessLevel;
import lombok.Await;
import lombok.Getter;
import lombok.Signal;
class ConditionExample {
@Getter(AccessLevel.PRIVATE)
private volatile boolean paused;
@Signal("canResume")
void unpause() {
paused = false;
}
@Await(conditionName = "canResume", conditionMethod="isPaused")
void pause() {
}
}
public class ConditionExample {
private final java.util.concurrent.locks.Lock $canResumeLock = new java.util.concurrent.locks.ReentrantLock();
private final java.util.concurrent.locks.Condition canResume = $canResumeLock.newCondition();
private volatile boolean paused;
void unpause() {
this.$canResumeLock.lock();
try {
paused = false;
this.canResume.signal();
} finally {
this.$canResumeLock.unlock();
}
}
void pause() {
this.$canResumeLock.lock();
try {
try {
while (this.isPaused()) this.canResume.await();
} catch (final java.lang.InterruptedException e) {
throw new java.lang.RuntimeException(e);
}
} finally {
this.$canResumeLock.unlock();
}
}
private boolean isPaused() {
return this.paused;
}
}
(Documentation pending)
Nothing to configure yet.
I am not able to run @Action. If I provide Action1 implementation it works.
implementation private static Action1 println() { return new Action1() { public void apply(final Object o) { System.out.println(o); } };
pom : com.github.peichhorn lombok-pg 0.11.3
<dependency>
<groupId>com.github.peichhorn</groupId>
<artifactId>lombok-pg</artifactId>
<version>0.11.3</version>
<classifier>runtime</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>