/// <summary> /// Obtains and ignores the next task that the <paramref name="executor"/> /// would otherwise execute, if one is immediately available, /// and then retries execution of task <paramref name="runnable"/>, unless the <paramref name="executor"/> /// is shut down, in which case task <paramref name="runnable"/> is instead discarded. /// </summary> /// <param name="runnable">the <see cref="Spring.Threading.IRunnable"/> task requested to be executed</param> /// <param name="executor">the <see cref="Spring.Threading.Execution.ThreadPoolExecutor"/> attempting to execute this task</param> public virtual void RejectedExecution(IRunnable runnable, ThreadPoolExecutor executor) { if (executor.IsShutdown) return; IRunnable head; executor.Queue.Poll(out head); executor.Execute(runnable); }
/// <summary> /// The constructor. /// </summary> /// <param name="cacheHostInformationPoller">The cache host information poller.</param> /// <param name="memCache">The mem cache to use for storing objects.</param> /// <param name="clientToCacheServiceHost">The client to cache service host.</param> /// <param name="cacheManagerClient">The cache manager client.</param> public CacheHostEngine(IRunnable cacheHostInformationPoller, MemCache memCache, ServiceHost clientToCacheServiceHost) { // Sanitize if (cacheHostInformationPoller == null) { throw new ArgumentNullException("cacheHostInformationPoller"); } if (memCache == null) { throw new ArgumentNullException("memCache"); } if (clientToCacheServiceHost == null) { throw new ArgumentNullException("clientToCacheServiceHost"); } // Set the cache host information poller _cacheHostInformationPoller = cacheHostInformationPoller; // Set the mem cache container instance MemCacheContainer.Instance = memCache; // Initialize the service hosts _clientToCacheServiceHost = clientToCacheServiceHost; }
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mCountdownRunnable = new Runnable(() => { int remainingSec = (int) Math.Max(0,(UIUtils.CONFERENCE_START_MILLIS - JavaSystem.CurrentTimeMillis()) / 1000); bool conferenceStarted = remainingSec == 0; if (conferenceStarted) { // Conference started while in countdown mode, switch modes and // bail on future countdown updates. messageHandler.PostDelayed(() => { Refresh(); }, 100); return; } int secs = remainingSec % 86400; int days = remainingSec / 86400; string str = Resources.GetQuantityString( Resource.Plurals.whats_on_countdown_title, days, days, DateUtils.FormatElapsedTime(secs)); countdownTextView.Text = str; // Repost ourselves to keep updating countdown messageHandler.PostDelayed(mCountdownRunnable, 1000); }); rootView = (ViewGroup) inflater.Inflate (Resource.Layout.FragmentWhatsOn, container); Refresh(); return rootView; }
public void SetUp() { _queue = MockRepository.GenerateStub<IBlockingQueue<IRunnable>>(); _runnable = MockRepository.GenerateMock<IRunnable>(); _callerRunsPolicy = new ThreadPoolExecutor.CallerRunsPolicy(); _threadPoolExecutor = new ThreadPoolExecutor(1, 1, TimeSpan.FromSeconds(1), _queue); }
private Object consume(IRunnable runnable, Object parameter) { var consumers = runnableManager.GetConsumers(runnable); var converter = consumers.FirstOrDefault(c => c.IsConvertable(parameter)); if (converter == null) return ExecuteRunnable(runnable, parameter); return converter.Convert(parameter, param => ExecuteRunnable(runnable, param)); }
public override void Sync(IRunnable runnable) { lock (_bin) { base.Sync(runnable); } }
public static void postOnAnimation(View view, IRunnable runnable) { if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) { SDK16.postOnAnimation(view, runnable); } else { view.PostDelayed(runnable, 16); } }
private Object produce(IRunnable runnable, Object result) { var producers = runnableManager.GetProducers(runnable); var converter = producers.FirstOrDefault(c => c.IsConvertable(result)); if (converter == null) return result; return converter.Convert(result); }
public void SetUp() { _queue = MockRepository.GenerateStub<IBlockingQueue<IRunnable>>(); _runnable = MockRepository.GenerateMock<IRunnable>(); _discardOldestPolicy = new ThreadPoolExecutor.DiscardOldestPolicy(); _threadPoolExecutor = Mockery.GeneratePartialMock<ThreadPoolExecutor>(1, 1, TimeSpan.FromSeconds(1), _queue); }
/** * Builds the task. * * @param runnable * The wrapped Runnable object. * @throws InvalidPatternException * If the supplied pattern is not valid. */ public RunnableTask(IRunnable runnable) { if (runnable == null) throw new ArgumentNullException("runnable", "runnable is null."); this._runnable = runnable; }
public void Run() { Buffer buf = new Buffer(300); // ?? Packet packet = new Packet(buf); thread = this; try { while (thread != null) { Socket socket = ss.Accept(); socket.setTcpNoDelay(true); Stream In = socket.getInputStream(); Stream Out = socket.getOutputStream(); ChannelDirectTCPIP channel = new ChannelDirectTCPIP(); channel.Init(); channel.setInputStream(In); channel.setOutputStream(Out); session.addChannel(channel); ((ChannelDirectTCPIP)channel).Host = host; ((ChannelDirectTCPIP)channel).Port = rport; ((ChannelDirectTCPIP)channel).OrgIPAddress = socket.getInetAddress().getHostAddress(); ((ChannelDirectTCPIP)channel).OrgPort = socket.Port; channel.connect(); if (channel.ExitStatus != -1) { } } } catch { } delete(); }
public override void Queue(IRunnable runnable) { using (RWLock.AsReader(_lock)) { SelectQueue(_lock, _queues, runnable).Enqueue(runnable); } }
public Thread NewThread (IRunnable r) { Thread t = new Thread (r); t.SetDaemon (true); t.Start (); return t; }
// =========================================================== // Methods // =========================================================== public void PostRunnable(/* final */ IRunnable pRunnable) { lock (_methodLock) { this.mRunnables.Add(pRunnable); } }
public static void RunRunnable(IRunnable runnable) { Thread thread = new Thread(runnable.Run); thread.IsBackground = true; thread.Priority = ThreadPriority.Lowest; thread.Start(); }
public static void PostOnAnimation(View view, IRunnable runnable) { if ((int)Android.OS.Build.VERSION.SdkInt >= (int)Android.OS.Build.VERSION_CODES.JellyBean) { PostOnAnimationJellyBean(view, runnable); } else { view.PostDelayed(runnable, SIXTY_FPS_INTERVAL); } }
Thread(IRunnable runnable, ThreadGroup grp, string name) { _thread = new System.Threading.Tasks.Task(InternalRun); this._runnable = runnable ?? this; _tgroup = grp ?? _defaultGroup; _tgroup.Add (this); }
/// <summary> Returns wrapped runnable that ensures that if an exception occurs /// during the execution, the specified exception handler is invoked. /// </summary> /// <param name="runnable">runnable for which exceptions are to be intercepted /// </param> /// <param name="handler">the exception handler to call when exception occurs /// during execution of the given runnable /// </param> /// <returns> wrapped runnable /// </returns> /// <exception cref="System.ArgumentNullException">If either parameter is <c>null</c></exception> public static IRunnable AssignExceptionHandler(IRunnable runnable, UncaughtExceptionHandlerDelegate handler) { if ( runnable == null ) throw new ArgumentNullException("runnable", "Runnable cannot be null"); if ( handler == null ) throw new ArgumentNullException("handler", "Handler cannot be null"); return new AnonymousClassRunnable(runnable, handler); }
public void Execute(IRunnable command) { if (!this.IsAcceptingNewTasks) { throw new RejectedExecutionException(); } this.Unwrap().Execute(command); }
public override void Execute(IRunnable command) { if (command == null) { throw new NullReferenceException("command"); } this.tasks.Enqueue(command); }
/// <summary> /// Role Service Constructor /// </summary> /// <param name="run">Task Manager</param> public TaskService(IRunnable run) { if (null == run) { throw new ArgumentNullException("run"); } this.run = run; }
public override IDisposable ScheduleDirect(IRunnable run, TimeSpan delay) { ScheduledRunnable sr = new ScheduledRunnable(run, null); IDisposable d = Task.Delay(delay).ContinueWith(t => sr.Run()); sr.SetFuture(d); return sr; }
public static Thread ExecuteAfter(string threadName, long timeInMillis, IRunnable runnable) { Thread t = new _Thread_96(timeInMillis, runnable); t.SetName(threadName); t.SetDaemon(true); t.Start(); return t; }
public override IDisposable ScheduleDirect(IRunnable run) { ScheduledRunnable sr = new ScheduledRunnable(run, null); IDisposable d = Task.Run(() => sr.Run()); sr.SetFuture(d); return sr; }
/// <summary> /// Execute the given command in a new thread. /// </summary> public virtual void Execute(IRunnable runnable) { lock (this) { Utils.FailFastIfInterrupted(); Thread thread = ThreadFactory.NewThread(runnable); thread.Start(); } }
Thread (IRunnable runnable, ThreadGroup grp, string name) { _thread = new System.Threading.Thread (InternalRun); this._runnable = runnable ?? this; _tgroup = grp ?? _defaultGroup; _tgroup.Add (this); if (name != null) _thread.Name = name; }
/** * Creates and executes a one-shot action that becomes enabled * after the given delay. * * @param task the task to execute * @param delay the time from now to delay execution * @param unit the time unit of the delay parameter * @return a Future representing pending completion of * the task and whose <tt>get()</tt> method will return * <tt>null</tt> upon completion */ public IFuture<object> schedule(IRunnable task, int delayMs) { if (!isOpen.get()) { throw new InvalidOperationException("CloseableExecutorService is closed"); } var futureTask = new InternalFutureTask<object>(this, task); return _scheduledExecService.schedule(futureTask, delayMs); }
/// <summary> /// The constructor. /// </summary> /// <param name="cacheHostServer">The cache host server.</param> public CacheHostRunner(IRunnable cacheHostServer) { // Sanitize if (cacheHostServer == null) { throw new ArgumentNullException("cacheHostServer"); } _cacheServer = cacheHostServer; }
public override void Start() { base.Start(); if (currentRunnable != null) currentRunnable.Stop(); currentRunnable = null; currentIndex = 0; }
public SliderView(Context paramContext, IAttributeSet paramAtributeSet, int paramint) : base(paramContext, paramAtributeSet, paramint) { this.hideSliderRunnable = new Runnable(() => hideSlider(true)); LayoutInflater.From(Context).Inflate(Resource.Layout.slider, this); slider = (SliderView)FindViewById(Resource.Id.slider_control); indeterminateSlider = ((ImageView)FindViewById(Resource.Id.indeterminate_slider)); hideSlider(false); hideIndeterminateSlider(false); }
public SchedulerRegistration(IRunnable action, ICancelable cancellation) { Action = action; Cancellation = cancellation; }
public override bool PostDelayed(IRunnable action, long delayMillis) { return(base.PostDelayed(action, delayMillis)); }
public override void Sync(IRunnable runnable) { ++_enclosing._numberOfSyncCalls; base.Sync(runnable); }
/// <summary> /// Creates a <see cref="FutureTask{T}"/> that will, upon running, execute the /// given <see cref="IRunnable"/>, and arrange that <see cref="GetResult()"/> /// will return the given <paramref name="result"/> upon successful completion. /// </summary> /// <param name="task">The runnable task.</param> /// <param name="result"> /// The result to return on successful completion. If /// you don't need a particular result, consider using /// constructions of the form: /// <code language="c#"> /// Future f = new FutureTask(runnable, default(T)) /// </code> /// </param> /// <exception cref="System.ArgumentNullException"> /// If the <paramref name="task"/> is <c>null</c>. /// </exception> public FutureTask(IRunnable task, T result) : this(Executors.CreateCallable(task, result)) { }
public override void Sync(IRunnable runnable) { FlushAllPages(); base.Sync(new _IRunnable_119(this, runnable)); }
public Thread() { _target = this; }
public abstract void Execute(IRunnable task);
public abstract void SyncFiles(IRunnable runnable);
public abstract void ClearRun(IRunnable run);
public Thread NewThread(IRunnable runnable) { return(_manager.NewManagedThread(runnable.Run, "T" + NextThreadId(false))); }
public void Execute(IRunnable command) { Execute(command.Run); }
public _IRunnable_119(CachingBin _enclosing, IRunnable runnable) { this._enclosing = _enclosing; this.runnable = runnable; }
public _IRunnable_41(ThreadPool4Impl _enclosing, IRunnable task) { this._enclosing = _enclosing; this.task = task; }
public virtual void Start(string taskName, IRunnable task) { Thread thread = ThreadFor(taskName, task); ActivateThread(thread); }
/// <summary> /// Queues or executes (depending on the implementation) the <see cref="IRunnable"/> /// </summary> /// <param name="run">The asynchronous task to be executed</param> /// <exception cref="RejectedExecutionException">Thrown when the service can't accept additional tasks.</exception> public abstract void Execute(IRunnable run);
public static object Compare(object newPoint, object lastCheckValue, IRunnable rightSide, OperatorType operatorType) { try { if (rightSide == null) { throw new Exception("I cannot found right side of condition please check if you are using empty parentheses just remove them"); } //if that was first condition //if (lastCheckValue == null) // return true;// (bool)rightSide.Run(newPoint); object rightValue = rightSide.Run(newPoint); Type leftType = null; if (lastCheckValue != null) { leftType = lastCheckValue.GetType(); } switch (operatorType) { //check 'and' condition case OperatorType.And: { return((bool)lastCheckValue && (bool)rightValue); } //check 'or' condition case OperatorType.Or: { return((bool)lastCheckValue || (bool)rightValue); } case OperatorType.Equal: { return(Equals(lastCheckValue, ConvertType(leftType, rightValue))); } case OperatorType.NotEqual: { return(!Equals(lastCheckValue, ConvertType(leftType, rightValue))); } case OperatorType.GreaterThan: { IComparable leftSideCompare = (IComparable)lastCheckValue; return(leftSideCompare.CompareTo(ConvertType(leftType, rightValue)) == 1); } case OperatorType.LessThan: { IComparable leftSideCompare = (IComparable)lastCheckValue; return(leftSideCompare.CompareTo(ConvertType(leftType, rightValue)) == -1); } case OperatorType.GreaterThanEqual: { IComparable leftSideCompare = (IComparable)lastCheckValue; int result = leftSideCompare.CompareTo(ConvertType(leftType, rightValue)); return(result >= 0); } case OperatorType.LessThanEqual: { IComparable leftSideCompare = (IComparable)lastCheckValue; int result = leftSideCompare.CompareTo(ConvertType(leftType, rightValue)); return(result <= 0); } default: throw new Exception($"I cannot support {operatorType} operator"); } } catch (Exception ex) { throw ex; } }
protected override void InternalScheduleOnce(TimeSpan delay, IRunnable action, ICancelable cancelable) { InternalSchedule(delay, TimeSpan.Zero, action, cancelable); }
/// <summary> /// /// </summary> /// <param name="job"></param> public void Add(IRunnable job) { jobs.Enqueue(job); NumJobs++; Interlocked.Increment(ref numJobsToRun); }
public PreferenceFragment() { mHandler = new MyHandler(this); mRequestFocus = new MyRunnable(this); }
public _IClosure4_85(ThreadedSyncBin _enclosing, IRunnable runnable) { this._enclosing = _enclosing; this.runnable = runnable; }
/// <summary> /// 回调 <see cref="IRunnable.Stop"/> 然后<see cref="IRunnable.WaitToStop"/>. /// </summary> public static void StopAndWaitToStop(this IRunnable runnable) { runnable.Stop(); runnable.WaitToStop(); }
public DummyJob(IRunnable actualJob) { ActualJob = actualJob; }
public virtual void Sync(IRunnable runnable) { _bin.Sync(runnable); }
protected virtual void WithContent(AbstractBufferContext context, IRunnable runnable ) { runnable.Run(); }
public _Thread_96(long timeInMillis, IRunnable runnable) { this.timeInMillis = timeInMillis; this.runnable = runnable; }
protected override void InternalScheduleRepeatedly(TimeSpan initialDelay, TimeSpan interval, IRunnable action, ICancelable cancelable) { InternalSchedule(initialDelay, interval, action, cancelable); }
public override void Execute(IRunnable run) { run.Run(); }
public override void Sync(IRunnable runnable) { WaitForPendingSync(); _lock.Run(new _IClosure4_85(this, runnable)); }
public Thread(IRunnable target, string name) { _target = target; SetName(name); }
public Thread(IRunnable target) { _target = target; }