Created
February 28, 2011 15:27
-
-
Save mpilquist/847465 to your computer and use it in GitHub Desktop.
Example of using custom executor with Akka 1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ExecutorService | |
import java.util.concurrent.atomic.AtomicReference | |
import akka.dispatch.ExecutorBasedEventDrivenDispatcher | |
import akka.dispatch.Dispatchers | |
import akka.dispatch.MailboxType | |
abstract class ExecutorDispatcher( | |
name: String, | |
throughput: Int = Dispatchers.THROUGHPUT, | |
throughputDeadlingTime: Int = Dispatchers.THROUGHPUT_DEADLINE_TIME_MILLIS, | |
mailboxType: MailboxType = Dispatchers.MAILBOX_TYPE) | |
extends ExecutorBasedEventDrivenDispatcher(name, throughput, throughputDeadlingTime, mailboxType) { | |
override val executorService = new AtomicReference[ExecutorService](createExecutor) | |
override def shutdown { | |
val old = executorService.getAndSet(createExecutor) | |
if (old != null) { | |
old.shutdownNow | |
} | |
} | |
protected def createExecutor: ExecutorService | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment