diff --git a/akka-docs/java/code/akka/docs/dispatcher/DispatcherDocTestBase.java b/akka-docs/java/code/akka/docs/dispatcher/DispatcherDocTestBase.java index d005ffcd6b..1aaa76ee11 100644 --- a/akka-docs/java/code/akka/docs/dispatcher/DispatcherDocTestBase.java +++ b/akka-docs/java/code/akka/docs/dispatcher/DispatcherDocTestBase.java @@ -123,30 +123,21 @@ public class DispatcherDocTestBase { } //#prio-mailbox - public static class PrioMailbox implements MailboxType { - - static final PriorityGenerator generator = new PriorityGenerator() { // Create a new PriorityGenerator, lower prio means more important - @Override - public int gen(Object message) { - if (message.equals("highpriority")) - return 0; // 'highpriority messages should be treated first if possible - else if (message.equals("lowpriority")) - return 100; // 'lowpriority messages should be treated last if possible - else if (message.equals(Actors.poisonPill())) - return 1000; // PoisonPill when no other left - else - return 50; // We default to 50 - } - }; - - private UnboundedPriorityMailbox priorityMailbox; - + public static class PrioMailbox extends UnboundedPriorityMailbox { public PrioMailbox(Config config) { // needed for reflective instantiation - priorityMailbox = new UnboundedPriorityMailbox(generator); - } - - public MessageQueue create(Option owner) { - return priorityMailbox.create(owner); + super(new PriorityGenerator() { // Create a new PriorityGenerator, lower prio means more important + @Override + public int gen(Object message) { + if (message.equals("highpriority")) + return 0; // 'highpriority messages should be treated first if possible + else if (message.equals("lowpriority")) + return 100; // 'lowpriority messages should be treated last if possible + else if (message.equals(Actors.poisonPill())) + return 1000; // PoisonPill when no other left + else + return 50; // We default to 50 + } + }); } } //#prio-mailbox diff --git a/akka-docs/scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala b/akka-docs/scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala index f26ac791d1..6717ad96cf 100644 --- a/akka-docs/scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala +++ b/akka-docs/scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala @@ -112,15 +112,14 @@ object DispatcherDocSpec { import akka.actor.ActorContext import com.typesafe.config.Config - val generator = PriorityGenerator { // Create a new PriorityGenerator, lower prio means more important - case 'highpriority ⇒ 0 // 'highpriority messages should be treated first if possible - case 'lowpriority ⇒ 100 // 'lowpriority messages should be treated last if possible - case PoisonPill ⇒ 1000 // PoisonPill when no other left - case otherwise ⇒ 50 // We default to 50 - } - // We create a new Priority dispatcher and seed it with the priority generator - class PrioMailbox(config: Config) extends UnboundedPriorityMailbox(generator) + class PrioMailbox(config: Config) extends UnboundedPriorityMailbox( + PriorityGenerator { // Create a new PriorityGenerator, lower prio means more important + case 'highpriority ⇒ 0 // 'highpriority messages should be treated first if possible + case 'lowpriority ⇒ 100 // 'lowpriority messages should be treated last if possible + case PoisonPill ⇒ 1000 // PoisonPill when no other left + case otherwise ⇒ 50 // We default to 50 + }) //#prio-mailbox class MyActor extends Actor {