I am creating an engine in a MPS-plugin using the MPS openapi. The engine is based on transaction memory and is uses ThreadLocals to hold the running transaction on specific threads. I tried to use the action listeners on ModelAccess to set and unset the transactions when necessary. This does not work.
According to the docs, jetbrains.mps.smodel.ActionDispatcher is using a counter to only signal listeners on the top-most actions. However, since a AtomicInteger is used for this purpose, this can lead to a start on one thread and a finish on another thread. If the counter would have been a ThreadLocal this would be symmetrically (on the same thread) and one top-most action at a time per thread.
Is this asynchronous listener behavior intentional?
Is there another way to listen to the start and finish of actions on the same thread as where the (top-most) action is run?