private EntryPointSubGraph EnsureSubGraph(FiniteState finiteState) { var subGraph = SubGraphDictionary.GetValueOrDefault(finiteState); if (subGraph != null) { return(subGraph); } subGraph = SubGraphDictionary[finiteState] = new EntryPointSubGraph(this, finiteState); subGraph.BuildExecutionGraph(); return(subGraph); }
internal void Initialize(IInstructionReader instructionReader, AutomataContext context) { if (ReferenceEquals(context.ProcessField, DummyProcess) == false) { throw new InvalidOperationException("Context is busy"); } _processResources = ProcessResources.ThreadLocalInstance.Value; _executionPathQueueBuilder = _processResources.ExecutionPathGroupBuilderPool.Get().AddReference(); _parallelThreads = _processResources.ThreadListPool.Get().AddReference(); _executionMethods = _automata.GetExecutionMethods(context); Context = context; Context.ProcessField = this; var entryPoint = context.EntryPoint; if (!(entryPoint is FiniteState state)) { return; } var instructionQueue = _processResources.InstructionQueuePool.Get().Mount(instructionReader, _automata); _entryPointSubGraph = _automata.EnsureSubGraph(state); var initNode = _entryPointSubGraph.InitNode; if (initNode.Safe == false) { initNode.MakeSafe(); } _currentThread = new Thread(initNode, instructionQueue, context.CreateContextStateInternal()) { Stack = _processResources.StackPool.Get().AddReference(), ExecutionQueue = _processResources.ExecutionPathPool.Get().AddReference(), PredicateResultQueue = _processResources.PredicateResultPool.Get().AddReference() }; }