Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kermitas/eed4e7ed8d0675adba76 to your computer and use it in GitHub Desktop.

Select an option

Save kermitas/eed4e7ed8d0675adba76 to your computer and use it in GitHub Desktop.
Prerequisites for Akka dispatcher.
package akka.dispatch
/**
* Composition over [[DefaultDispatcherPrerequisites]] that replaces thread factory with one that allow to configure thread priority.
*
* @param newThreadPriority priority that will be set to each newly created thread
* should be between Thread.MIN_PRIORITY (which is 1) and Thread.MAX_PRIORITY (which is 10)
*/
class PriorityThreadsDispatcherPrerequisites(prerequisites: DispatcherPrerequisites, newThreadPriority: Int) extends DefaultDispatcherPrerequisites(
eventStream = prerequisites.eventStream,
scheduler = prerequisites.scheduler,
dynamicAccess = prerequisites.dynamicAccess,
settings = prerequisites.settings,
mailboxes = prerequisites.mailboxes,
defaultExecutionContext = prerequisites.defaultExecutionContext,
threadFactory = new PriorityThreadFactory(prerequisites, newThreadPriority)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment