//Loads stl, makes computations ("classify" each facet), then removes the facet data from memory. private void process_stl_async(string stl_location, int process_count) { //Build all threads, start. (This snippet may be worth saving?) Thread[] threads = new Thread[process_count]; thread_signin = new bool[process_count]; for (int i = 0; i < process_count; i++) { //Lambda expressions pass by reference. Dereferencing is necessary here. int dereference_i = i; threads[i] = new Thread(() => process_stl_singleprocess(dereference_i, process_count)); } foreach (Thread t in threads) { t.Start(); } //Wait for all threads to complete. while (!MathTools.CheckAll(thread_signin)) { Thread.Sleep(1); } //Combine tables and reduce. lookup_table = StlClassificationTable.CombineReduce(volatile_tables); }
//Computes relevant tags for each node in parallel private void ComputeRelevantsAsync(int process_count) { Thread[] threads = new Thread[process_count]; thread_signin = new bool[process_count]; par_ext_model_nodes = new List <ModelNode> [process_count]; par_ext_relevant_indices = new List <int[]> [process_count]; for (int i = 0; i < process_count; i++) { par_ext_model_nodes[i] = new List <ModelNode>(); par_ext_relevant_indices[i] = new List <int[]>(); //Lambda expressions pass by reference. Dereferencing is necessary here. int dereference_i = i; threads[i] = new Thread(() => ComputeRelevantSingleProcess(dereference_i, process_count)); } foreach (Thread t in threads) { t.Start(); } //Wait for all threads to complete. while (!MathTools.CheckAll(thread_signin)) { Thread.Sleep(1); } }