示例#1
0
        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);
        }
示例#2
0
        public void AddToQueue(CompilerResult compilerResult)
        {
            if (compilerResult.Attemps == 0)             //Count the method only on first try
            {
                Interlocked.Increment(ref _totalMethods);
            }

            if (compilerResult.Attemps++ > 5)
            {
                compilerResult.Result = "Method exceeded compile attemps: " + compilerResult.Result;
            }
            else
            {
                Interlocked.Increment(ref _totalQueued);
                if (!_channel.Writer.TryWrite(compilerResult))
                {
                    Debug.Assert(false);
                }
            }
        }