public NodeValueReadyEventArgs(ProtoCore.Mirror.RuntimeMirror mirror, uint nodeId, EventStatus resultStatus, String errorString) { this.RuntimeMirror = mirror; this.NodeId = nodeId; ResultStatus = resultStatus; ErrorString = errorString; }
public void TestPeriodicUpdate01() { int rhs = 0; string code = String.Format("a = {0};", rhs.ToString()); Guid guid = System.Guid.NewGuid(); // First run // a = 1 List <Subtree> added = new List <Subtree>(); Subtree st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code); st.IsInput = true; added.Add(st); var syncData = new GraphSyncData(null, added, null); liverunner.UpdateGraph(syncData); instrStreamStart = runtimeDiagnostics.GetExecutableInstructionCount(); ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 0); List <Subtree> modified = null; const int maxUpdate = 100; for (int n = 1; n <= maxUpdate; ++n) { // Modify a code = String.Format("a = {0};", n.ToString()); modified = new List <Subtree>(); st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, code); st.IsInput = true; modified.Add(st); syncData = new GraphSyncData(null, null, modified); liverunner.UpdateGraph(syncData); instrStreamEnd = runtimeDiagnostics.GetExecutableInstructionCount(); Assert.AreEqual(instrStreamStart, instrStreamEnd); } mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 100); }
public void TestInstructionStreamMemory_FunctionRedefinition01() { List <string> codes = new List <string>() { "def f() {return = 1;}", "a = f();", "def f() {return = 2;}" }; Guid guid1 = System.Guid.NewGuid(); Guid guid2 = System.Guid.NewGuid(); // First run List <Subtree> added = new List <Subtree>(); Subtree st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid1, codes[0]); added.Add(st); st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid2, codes[1]); added.Add(st); var syncData = new GraphSyncData(null, added, null); liverunner.UpdateGraph(syncData); instrStreamStart = runtimeDiagnostics.GetExecutableInstructionCount(); ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 1); // Modify function List <Subtree> modified = new List <Subtree>(); st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid1, codes[2]); modified.Add(st); syncData = new GraphSyncData(null, null, modified); liverunner.UpdateGraph(syncData); instrStreamEnd = runtimeDiagnostics.GetExecutableInstructionCount(); mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 2); Assert.AreEqual(instrStreamStart, instrStreamEnd); }
public void TestInstructionStreamMemory_SimpleWorkflow01() { List <string> codes = new List <string>() { "a = 1;", "a = 2;" }; Guid guid = System.Guid.NewGuid(); // First run // a = 1 List <Subtree> added = new List <Subtree>(); Subtree st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, codes[0]); st.IsInput = true; added.Add(st); var syncData = new GraphSyncData(null, added, null); liverunner.UpdateGraph(syncData); instrStreamStart = runtimeDiagnostics.GetExecutableInstructionCount(); ProtoCore.Mirror.RuntimeMirror mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 1); // Modify // a = 2 List <Subtree> modified = new List <Subtree>(); st = ProtoTestFx.TD.TestFrameWork.CreateSubTreeFromCode(guid, codes[1]); st.IsInput = true; modified.Add(st); syncData = new GraphSyncData(null, null, modified); liverunner.UpdateGraph(syncData); instrStreamEnd = runtimeDiagnostics.GetExecutableInstructionCount(); mirror = liverunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 2); Assert.AreEqual(instrStreamStart, instrStreamEnd); }
/// <summary> /// Inspects the VM for the value of a node given its variable name. /// As opposed to QueryNodeValue, this does not use the Expression Interpreter /// This will block until the value is available. /// It will only serviced when all ASync calls have been completed /// </summary> /// <param name="nodeId"></param> /// <returns></returns> public ProtoCore.Mirror.RuntimeMirror InspectNodeValue(string nodeName) { while (true) { lock (taskQueue) { //Spin waiting for the queue to be empty if (taskQueue.Count == 0) { //No entries and we have the lock //Synchronous query to get the node // Comment Jun: all symbols are in the global block as there is no notion of scoping the the graphUI yet. const int blockID = 0; ProtoCore.Mirror.RuntimeMirror runtimeMirror = ProtoCore.Mirror.Reflection.Reflect(nodeName, blockID, runnerCore); return(runtimeMirror); } } Thread.Sleep(0); } }
public NodeValueReadyEventArgs(ProtoCore.Mirror.RuntimeMirror mirror, uint nodeId) : this(mirror, nodeId, EventStatus.OK, null) { }