feat: Add UntypedAbstractActorWithTimers (#1361)
This commit is contained in:
parent
7647f13b9d
commit
a9584ec520
2 changed files with 37 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ import org.apache.pekko.actor.PoisonPill;
|
|||
import org.apache.pekko.actor.Props;
|
||||
import org.apache.pekko.actor.Terminated;
|
||||
import org.apache.pekko.actor.AbstractActor;
|
||||
import org.apache.pekko.actor.UntypedAbstractActorWithTimers;
|
||||
import org.apache.pekko.testkit.TestActor.AutoPilot;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -92,7 +93,7 @@ public class TestKitDocTest extends AbstractJavaTest {
|
|||
|
||||
// #timer
|
||||
static class TestTimerActor extends AbstractActorWithTimers {
|
||||
private static Object SCHED_KEY = "SchedKey";
|
||||
private static String SCHED_KEY = "SchedKey";
|
||||
|
||||
static final class TriggerScheduling {}
|
||||
|
||||
|
|
@ -107,6 +108,27 @@ public class TestKitDocTest extends AbstractJavaTest {
|
|||
getTimers().startSingleTimer(SCHED_KEY, new ScheduledMessage(), Duration.ofMillis(500));
|
||||
}
|
||||
}
|
||||
|
||||
static class TestTimerUntypedActor extends UntypedAbstractActorWithTimers {
|
||||
private static String SCHED_KEY = "SchedKey";
|
||||
|
||||
static final class TriggerScheduling {}
|
||||
|
||||
static final class ScheduledMessage {}
|
||||
|
||||
@Override
|
||||
public void onReceive(Object message) throws Throwable {
|
||||
if (message instanceof TriggerScheduling) {
|
||||
triggerScheduling();
|
||||
} else {
|
||||
unhandled(message);
|
||||
}
|
||||
}
|
||||
|
||||
void triggerScheduling() {
|
||||
getTimers().startSingleTimer(SCHED_KEY, new ScheduledMessage(), Duration.ofMillis(500));
|
||||
}
|
||||
}
|
||||
// #timer
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue