コード例 #1
0
ファイル: SwarmMemory.cs プロジェクト: shranjan/pinac
 public void distributeParallelCode(string[] statement)
 {   
     //1. get IP to # CPU
     List<string> calculationComputers = new List<string>();
     Hashtable IPtoCPU = new Hashtable();//should come from other modules
     int totalCPU = 0;
     foreach (DictionaryEntry allPeers in IPtoCPU)
     {
         foreach (DictionaryEntry permitted in permissions)
         {
             string[] temp = (string[])permitted.Value;
             if (allPeers.Key.ToString() == permitted.Key.ToString() && temp[0].ToString() == "true")
             {
                 totalCPU = totalCPU + int.Parse(allPeers.Value.ToString());
                 calculationComputers.Add(permitted.Key.ToString());
             }
         }
     }
     int LinePerCPU = (int)(statement.Length / totalCPU);
     string PortionStatement = PortionsIPXML(LinePerCPU, statement, calculationComputers, IPtoCPU);
     List<string> endPoints = Peers();            
     foreach (string dest in endPoints)
     {
         ThreadProc thrd = new ThreadProc(dest.ToString(), PortionStatement);
         Thread t = new Thread(new ThreadStart(thrd.sendThread));
         t.Start();
     }            
 }