private CompilerResult ProcessQueue(int threadID = 0) { CompilerResult method = default; try { method = MethodScheduler.GetMethodToCompile(); if (method == null) { return(null); } method.CompiledMethod = CompileMethod(method.Method, threadID); method.Result = "OK"; return(method); } catch (Exception e) { method.Result = e.Message; MethodScheduler.AddToQueue(method); } return(method); }
private MosaMethod ProcessQueue(int threadID = 0) { var method = MethodScheduler.GetMethodToCompile(); if (method == null) { return(null); } return(CompileMethod(method, threadID)); }
private MosaMethod ProcessQueue(int threadID = 0) { try { var methodData = MethodScheduler.GetMethodToCompile(); if (methodData == null) { return(null); } CompileMethod(methodData.Method, threadID); return(methodData.Method); } catch (Exception e) { return(null); } }
private MosaMethod ProcessQueue(int threadID = 0) { try { WorkIncrement(); var method = MethodScheduler.GetMethodToCompile(); if (method == null) { return(null); } return(CompileMethod(method, threadID)); } finally { WorkDecrement(); } }
private void ExecuteThreadedCompilePass(int maxThreads) { //maxThreads = 512; int threadLaunched = 0; var threadIDs = new Stack <int>(); for (var i = 1; i <= maxThreads; i++) { threadIDs.Push(i); } while (true) { int launched; lock (threadIDs) { launched = threadLaunched; } // are available threads? if (launched < maxThreads) { // Yes - is there a method to compile var method = MethodScheduler.GetMethodToCompile(); if (method != null) { int threadID; lock (threadIDs) { threadID = threadIDs.Pop(); threadLaunched++; } ThreadPool.QueueUserWorkItem((state) => { CompileMethod(method, threadID); // lets check for another one while (true) { var method2 = MethodScheduler.GetMethodToCompile(); if (method2 == null) { break; } CompileMethod(method2, threadID); } lock (threadIDs) { threadIDs.Push(threadID); threadLaunched--; } }); } else { if (launched == 0) { return; // all done } } } else { Thread.Yield(); } } }