public Thread invoke(object action_id, Action reaction, out IActionFuture future) { int partner_size = channel.RemoteSize; int value = ActionDef.action_ids[action_id]; MPI.RequestList request_list = new MPI.RequestList(); for (int i = 0; i < partner_size; i++) { MPI.Request req = channel.ImmediateSend <object>(value, i, value); request_list.Add(req); } for (int i = 0; i < partner_size; i++) { MPI.ReceiveRequest req = channel.ImmediateReceive <object>(i, value); request_list.Add(req); } ManualResetEvent sync = new ManualResetEvent(false); ActionFuture future_ = new ActionFuture(request_list, sync); future = future_; Thread t = new Thread(new ThreadStart(() => handle_request(future_, sync, reaction))); t.Start(); return(t); }
void handle_request(ActionFuture future, ManualResetEvent sync) { Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": HANDLE REQUEST 1"); future.RequestList.WaitAll(); Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": HANDLE REQUEST 2"); sync.Set(); Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": HANDLE REQUEST 3"); future.setCompleted(); Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": HANDLE REQUEST 4"); }
public Thread invoke(object action_id, Action reaction, out IActionFuture future) { Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": INVOKE ACTION " + action_id + " 0"); RequestList request_list = synchronize_action(action_id); Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": INVOKE ACTION " + action_id + " 1"); ManualResetEvent sync = new ManualResetEvent(false); ActionFuture future_ = new ActionFuture(request_list, sync); future = future_; Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": INVOKE ACTION " + action_id + " 2"); Thread t = new Thread(new ThreadStart(() => handle_request(future_, sync, reaction))); t.Start(); Trace.WriteLineIf(this.TraceFlag == true, this.ThisFacetInstance + "/" + this.Rank + ": INVOKE ACTION " + action_id + " 3"); return(t); }
void handle_request(ActionFuture future, ManualResetEvent sync, Action reaction) { handle_request(future, sync); reaction(); }
void handle_request(ActionFuture future, ManualResetEvent sync) { future.RequestList.WaitAll(); sync.Set(); future.setCompleted(); }