-
Notifications
You must be signed in to change notification settings - Fork 44
@Signal @Await @SignalBeforeAwaitAfter
framiere edited this page Nov 24, 2011
·
2 revisions
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() {
}
}
class ConditionExample {
private volatile boolean paused;
private final java.util.concurrent.locks.Lock $canResumeLock = new java.util.concurrent.locks.ReentrantLock();
private final java.util.concurrent.locks.Condition canResume = $canResumeLock.newCondition();
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 RuntimeException(e);
}
} finally {
this.$canResumeLock.unlock();
}
}
private boolean isPaused() {
return this.paused;
}
}
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>