Пример #1
0
        /// <summary>
        /// 获取JobThread
        /// </summary>
        /// <returns>true表示新创建的线程,否则表示原有的</returns>
        public bool GetJobThread(TriggerParam triggerParam, out JobThread jobThread)
        {
            lock (_syncObject)
            {
                if (_jobThreads.TryGetValue(triggerParam.jobId, out jobThread))
                {
                    if (jobThread.Stopped)
                    {
                        jobThread = CreateJobThread(triggerParam.jobId);
                        return(true);
                    }

                    if (jobThread.IsRunningOrHasQueue() && Constants.ExecutorBlockStrategy.COVER_EARLY == triggerParam.executorBlockStrategy)
                    {
                        jobThread.Interrupt("block strategy effect:" + triggerParam.executorBlockStrategy);
                        jobThread = CreateJobThread(triggerParam.jobId);
                        return(true);
                    }

                    return(false);
                }
                else
                {
                    jobThread = CreateJobThread(triggerParam.jobId);
                    return(true);
                }
            }
        }
Пример #2
0
        private ReturnT IdleBeat(int jobId)
        {
            JobThread jobThread = _jobThreadFactory.FindJobThread(jobId);

            if (jobThread != null && jobThread.IsRunningOrHasQueue())
            {
                return(ReturnT.CreateFailedResult("job thread is running or has trigger queue."));
            }
            return(ReturnT.SUCCESS);
        }