Let Dispatcher handle future matches and don't store postponed matches (fixes MPSCR-37)

This commit is contained in:
Grigorii Kirgizov 2020-02-05 18:51:35 +03:00
parent f61c436809
commit a1682106d8
2 changed files with 7 additions and 5 deletions

View File

@ -233,16 +233,14 @@ internal class ConstraintsProcessing(private var dispatchingFront: Dispatcher.Di
}
val matches = dispatchingFront.matches().toList()
val newCurrentMatches =
val currentMatches =
// todo: assert that there can be no future matches on non-principal occurrences?
// with that move withPostponedMatches to else-branch
if (isFront() || !active.isPrincipal()) {
matches
} else {
assert( matches.all { ispec.isPrincipal(it.rule()) } )
execQueue.postponeFutureMatches(matches)
}
val currentMatches = execQueue.withPostponedMatches(active, newCurrentMatches)
val outStatus = currentMatches.fold(inStatus) { status, match ->
if (activationChunk != null && !isFront()) {

View File

@ -106,8 +106,12 @@ internal class ExecutionQueue(
// if it is a future match
if (pos != null && journalIndex.compare(lastIncrementalRootPos, pos) < 0) {
val idOcc = Id(occChunk.occ)
postponedMatches[idOcc] = (postponedMatches[idOcc] ?: emptyList()) + listOf(m)
// val idOcc = Id(occChunk.occ)
// postponedMatches[idOcc] = (postponedMatches[idOcc] ?: emptyList()) + listOf(m)
// TODO: Seems, Dispatcher will again return these unconsumed
// future matches on this offered activation,
// so there's no need to store them.
// Remove extra logic with 'postponedMatches'.
offer(pos, occChunk)
} else {
currentMatches.add(m)