From a1682106d8621622d06a53ed7db27bf7ea47d590 Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Wed, 5 Feb 2020 18:51:35 +0300 Subject: [PATCH] Let Dispatcher handle future matches and don't store postponed matches (fixes MPSCR-37) --- .../logic/reactor/core/internal/ConstraintsProcessing.kt | 4 +--- .../mps/logic/reactor/core/internal/ExecutionQueue.kt | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt index b6d8d423..595db270 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ConstraintsProcessing.kt @@ -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()) { diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt index 4b2ea94a..9e637666 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ExecutionQueue.kt @@ -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)