Skip to content

Commit

Permalink
Fixes race condition in waiting execution queue (#246)
Browse files Browse the repository at this point in the history
When several actions were queued concurrently in the same
WaitingExecutionQueue, only the last one remained.
  • Loading branch information
dufrannea authored Mar 8, 2018
1 parent 7248bc6 commit 562711e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ trait WaitingExecutionQueue {
}

lazy val _running = Ref(Set.empty[(Execution[_], DelayedResult[_])])
lazy val _waiting = Ref(SortedSet.empty[(Execution[_], DelayedResult[_])](Ordering.by(_._1)))
lazy val _waiting = Ref(
SortedSet.empty[(Execution[_ <: Scheduling], DelayedResult[_])](
Ordering.by[(Execution[_ <: Scheduling], DelayedResult[_]), (Execution[_], Int)]({
case (execution, delayedResult) => execution -> delayedResult.hashCode
})))

def waiting: Set[Execution[_]] = _waiting.single().map(_._1)
def running: Set[Execution[_]] = _running.single().map(_._1)
Expand Down

0 comments on commit 562711e

Please sign in to comment.