public void run(FunctionExit callback, EventQueue eventqueue) { /*sclass*/ c_c1 /*/sclass*/ job = new /*sclass*/ c_c1/*/sclass*/ (callback, null, eventqueue); job.run(); }
public void Run(FunctionExit callback, EventQueue eventqueue) { m_callback = callback; m_eventqueue = eventqueue; m_thread = new Thread(RunThread); m_thread.Start(); }
public /*cname*/ c_c1/*/cname*/ (FunctionExit exit, FunctionQueue queue, EventQueue eventqueue) : base(exit, queue, eventqueue) { entry = /*centry*/ fn_start /*/centry*/; /*varinit*/ /*cvarscope*/ g /*/cvarscope*/["/*cvarname*/x/*/cvarname*/"] = /*cvarvalue*/ 1 /*/cvarvalue*/; /*/varinit*/ lock (i) { if (!_isInitialised) { _isInitialised = true; NodeNames = new Dictionary <string, string>(); IncomingTransitions = new Dictionary <string, Dictionary <string, bool> >(); OutgoingTransitions = new Dictionary <string, Dictionary <string, bool> >(); /*nodename*/ NodeNames.Add("/*cnodecodename*/x/*/cnodecodename*/", "/*cnoderealname*/x/*/cnoderealname*/"); /*/nodename*/ /*transition*/ if (!OutgoingTransitions.ContainsKey("/*cnodestartname*/x/*/cnodestartname*/")) { OutgoingTransitions.Add("/*cnodestartname*/x/*/cnodestartname*/", new Dictionary <string, bool>()); } OutgoingTransitions["/*cnodestartname*/x/*/cnodestartname*/"].Add("/*cnodeendname*/x/*/cnodeendname*/", true); if (!IncomingTransitions.ContainsKey("/*cnodeendname*/x/*/cnodeendname*/")) { IncomingTransitions.Add("/*cnodeendname*/x/*/cnodeendname*/", new Dictionary <string, bool>()); } IncomingTransitions["/*cnodeendname*/x/*/cnodeendname*/"].Add("/*cnodestartname*/x/*/cnodestartname*/", true); /*/transition*/ /*gvarinit*/ /*cvarscope*/ g /*/cvarscope*/["/*cvarname*/x/*/cvarname*/"] = /*cvarvalue*/ 1 /*/cvarvalue*/; /*/gvarinit*/ } } }
public iliClass(FunctionExit exit, FunctionQueue queue, EventQueue eventqueue) { l = new Hashtable(); i = new Hashtable(); i["exit"] = exit; if (queue == null) { queue = go_to; q = new Queue(); i["slave"] = false; } else { i["slave"] = true; } i["queue"] = queue; i["eventqueue"] = eventqueue; }
public void init(FunctionExit exit, FunctionQueue queue, EventQueue eventqueue) { i["exit"] = exit; i["queue"] = queue; i["eventqueue"] = eventqueue; }
virtual public void go_up() { FunctionExit f = (FunctionExit)i["exit"]; f(go_exit()); }
int RunnerEventqueue(Hashtable data, FunctionExit listener) { data["pid"] = m_pid; data["gid"] = m_gid; return(m_eventqueue(data, listener)); }
int eventqueue(Hashtable data, FunctionExit port) { int returnValue = 0; EventPoint l = new EventPoint(); l.data = data; l.port = port; string eventType = "raise"; if (l.data.Contains("systemEvent")) { eventType = l.data["systemEvent"].ToString(); l.data.Remove("systemEvent"); } int pid = 0; if (l.data.Contains("pid")) { pid = (int)l.data["pid"]; l.pid = pid; l.data.Remove("pid"); } int id = 0; if (l.data.Contains("gid")) { id = (int)l.data["gid"]; l.gid = id; l.data.Remove("gid"); } lock (m_RaisedEvents) { if (eventType == "raise") { int eid = m_rand.Next(1, Int32.MaxValue); while (m_RaisedEvents.ContainsKey(eid)) { eid = m_rand.Next(1, Int32.MaxValue); } m_RaisedEvents[eid] = l; returnValue = eid; if (l.port == null) { m_EventResults[eid] = new Queue(); } foreach (int lid in m_EventListeners.Keys) { if (IsRespectiveListener(l, m_EventListeners[lid].data)) { Hashtable h = Utils.Clone(l.data); h.Add("systemEventId", eid); m_EventListeners[lid].port(h); } } if (m_Runners.ContainsKey(pid)) { lock (m_Runners[pid]) { Monitor.PulseAll(m_Runners[pid]); } } } else if (eventType == "query") { Hashtable response = new Hashtable(); int i = 0; foreach (int eid in m_RaisedEvents.Keys) { if (m_RaisedEvents[eid].data.ContainsKey("system")) { if (m_RaisedEvents[eid].data["system"] as String == "EventTimeout") { if (DateTime.FromBinary(Convert.ToInt64(m_RaisedEvents[eid].data["value"])).CompareTo(DateTime.Now) <= 0) { // TODO: remove key from m_RaisedEvents and m_EventResults tables } } } if (IsRespectiveListener(m_RaisedEvents[eid], l.data)) { response.Add(i++, eid); } } l.port(response); } else if (eventType == "fetch") { Hashtable response = new Hashtable(); bool success = true; if (l.data.Contains("systemEventId")) { int eventId = Convert.ToInt32(l.data["systemEventId"]); if (!m_RaisedEvents.ContainsKey(eventId)) { success = false; } else { response = Utils.Clone(m_RaisedEvents[eventId].data); } } else { success = false; } if (!success) { response.Add("success", false); } l.port(response); } else if (eventType == "answer") { Hashtable response = new Hashtable(); bool success = true; if (l.data.Contains("systemEventId")) { int eventId = Convert.ToInt32(l.data["systemEventId"]); l.data.Remove("systemEventId"); if (!m_RaisedEvents.ContainsKey(eventId)) { success = false; } else { bool close = false; if (l.data.Contains("systemEventClose")) { close = Convert.ToBoolean(l.data["systemEventClose"]); } if (m_RaisedEvents[eventId].port != null) { m_RaisedEvents[eventId].port(l.data); } else { m_EventResults[eventId].Enqueue(l.data); lock (m_EventResults[eventId]) { Monitor.PulseAll(m_EventResults[eventId]); } } if (close) { if (m_RaisedEvents[eventId].port != null) { m_RaisedEvents.Remove(eventId); } else { m_RaisedEvents[eventId].data.Clear(); m_RaisedEvents[eventId].data.Add("system", "EventTimeout"); m_RaisedEvents[eventId].data.Add("value", DateTime.Now.AddMinutes(5).ToBinary()); } } } } else { success = false; } response.Add("success", success); l.port(response); } else if (eventType == "close") { Hashtable response = new Hashtable(); bool success = true; if (l.data.Contains("systemEventId")) { int eventId = Convert.ToInt32(l.data["systemEventId"]); if (!m_RaisedEvents.ContainsKey(eventId)) { success = false; } else { if (m_RaisedEvents[eventId].port != null) { m_RaisedEvents.Remove(eventId); } else { m_RaisedEvents[eventId].data.Clear(); m_RaisedEvents[eventId].data.Add("system", "EventTimeout"); m_RaisedEvents[eventId].data.Add("value", DateTime.Now.AddMinutes(5).ToBinary()); } } } else if (l.data.Contains("systemListenerId")) { int listenerId = Convert.ToInt32(l.data["systemListenerId"]); if (!m_EventListeners.ContainsKey(listenerId)) { success = false; } else { m_EventListeners.Remove(listenerId); } } else { success = false; } response.Add("success", success); l.port(response); } else if (eventType == "listen") { int lid = m_rand.Next(1, Int32.MaxValue); while (m_EventListeners.ContainsKey(lid)) { lid = m_rand.Next(1, Int32.MaxValue); } m_EventListeners[lid] = l; returnValue = lid; foreach (int eid in m_RaisedEvents.Keys) { if (IsRespectiveListener(m_RaisedEvents[eid], l.data)) { Hashtable h = Utils.Clone(m_RaisedEvents[eid].data); h.Add("systemEventId", eid); l.port(h); } } } else if (eventType == "systemLoad") // internal, direct proccessing { if (l.data.ContainsKey("assembly")) { l.data.Remove("assembly"); } if (l.data.Contains("projectName")) { string projectName = Convert.ToString(l.data["projectName"]); int projectId; if (!m_ProjectsByName.ContainsKey(projectName)) { projectId = LoadProject(projectName); } else { projectId = m_ProjectsByName[projectName]; } lock (m_ProjectsByID) { if (m_Builds.ContainsKey(projectId)) { l.data.Add("assembly", m_Builds[projectId].Assembly); } } } } } Console.WriteLine("Node raised an event"); return(returnValue); }