I implemented in Java what I called the "folding queue", i.e. LinkedBlockingQueue used by ExecutorService. The idea is that each task as a unique identifier, if it is in the queue, and the other task is sent through the same identifier, it is not added to the queue. Java code is as follows:
public final class FoldablePricingQueue extends LinkedBlockingQueue<Runnable> { @Override public boolean offer(final Runnable runnable) { if (contains(runnable)) { return true;
Themes must be pre-launched, but this is a small detail. I have an Abstract class that implements Runnable that takes a unique identifier ... this is the one that was passed in
I would like to implement the same logic using Scala and Akka (Actors). I will need to have access to the mailbox, and I think I will need to override! method and check the mailbox for the event .. has anyone done this before?
source share