Skip to content

Instantly share code, notes, and snippets.

@mig35
Created March 30, 2020 09:27
Show Gist options
  • Save mig35/4ea7d70ef8fc340e82ac12f747b3417c to your computer and use it in GitHub Desktop.
Save mig35/4ea7d70ef8fc340e82ac12f747b3417c to your computer and use it in GitHub Desktop.
open class SingleStrategy : ExecutionStrategy {
override fun shouldAddToPendingActions(
pendingActionCommands: RemoveOnlyList<ActionCommand<*, *>>,
runningActionCommands: List<ActionCommand<*, *>>
): Boolean =
!pendingActionCommands.any { it.strategy is SingleStrategy }
&& !runningActionCommands.any { it.strategy is SingleStrategy }
override fun shouldBlockOtherTask(pendingActionCommand: ActionCommand<*, *>): Boolean =
true
override fun shouldExecuteAction(
pendingActionCommands: RemoveOnlyList<ActionCommand<*, *>>,
runningActionCommands: List<ActionCommand<*, *>>
): Boolean =
runningActionCommands.isEmpty()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment