Esempio n. 1
0
 protected override void OnResume()
 {
     base.OnResume();
     dataItemGeneratorFuture = generatorExecutor.ScheduleWithFixedDelay(new DataItemGenerator()
     {
         Activity = this
     }, 1, 5, TimeUnit.Seconds);
 }
Esempio n. 2
0
 // guarded by super#lifecycleLock
 protected override void DoStop()
 {
     if (_runningTask != null)
     {
         _runningTask.Cancel(true);
     }
     _runningTask = null;
 }
		private void StartPlayingHandler()
		{
			var handler = new Handler();
			var runnable = new Runnable(() => { handler.Post(OnPlaying); });
			if (!_executorService.IsShutdown)
			{
				_scheduledFuture = _executorService.ScheduleAtFixedRate(runnable, 100, 1000, TimeUnit.Milliseconds);
			}
		}
        private void StartBufferingSchedule()
        {
            var handler  = new Handler();
            var runnable = new Runnable(() => { handler.Post(OnBuffering); });

            if (!_executorService.IsShutdown)
            {
                _scheduledFuture = _executorService.ScheduleAtFixedRate(runnable, 100, 1000, TimeUnit.Milliseconds);
            }
        }
 public void Start()
 {
     lock (_lifecycleMonitor) {
         if (IsRunning())
         {
             return;
         }
         AssertUtils.State(_taskScheduler != null, "TaskScheduler must not be null");
         _reaperFutureTask = _taskScheduler.Schedule(new PrunerTask(this), new IntervalTrigger(_reaperInterval));
     }
 }
Esempio n. 6
0
        private void StartPlayingHandler()
        {
#pragma warning disable 618
            var handler = new Handler();
#pragma warning restore 618

            var runnable = new Runnable(() => { handler.Post(OnPlaying); });
            if (!_executorService.IsShutdown)
            {
                _scheduledFuture = _executorService.ScheduleAtFixedRate(runnable, 100, 1000, TimeUnit.Milliseconds);
            }
        }
Esempio n. 7
0
        // LifecycleSupport implementation

        // guarded by super#lifecycleLock
        protected override void DoStart()
        {
            if (!_initialized)
            {
                OnInit();
            }
            if (TaskScheduler == null)
            {
                throw new InvalidOperationException("unable to start polling, no taskScheduler available");
            }

            _runningTask = TaskScheduler.Schedule(_poller, _trigger);
        }
Esempio n. 8
0
 /// <summary>
 ///     Creates a new <seealso cref="Meter" />.
 /// </summary>
 /// <param name="scheduledExecutorService">background thread for updating the rates</param>
 /// <param name="eventType">
 ///     the plural name of the event the meter is measuring (e.g., {@code"requests"})
 /// </param>
 /// <param name="rateUnit">the rate unit of the new meter</param>
 /// <param name="clock">the clock to use for the meter ticks</param>
 internal Meter(
     IScheduledExecutorService scheduledExecutorService,
     string eventType,
     TimeUnit rateUnit,
     Clock clock)
 {
     RateUnit = rateUnit;
     EventType = eventType;
     _iFuture = scheduledExecutorService.ScheduleAtFixedRate(
         Tick, 
         TimeUnitHelper.ToTimeSpan(INTERVAL, TimeUnit.SECONDS),
         TimeUnitHelper.ToTimeSpan(INTERVAL, TimeUnit.SECONDS));
     this.clock = clock;
     startTime = this.clock.Tick;
 }
Esempio n. 9
0
        private void CheckThreadCount()
        {
            VerboseLog("{0:000}|CheckThreadCount: CoreSize: {1}; maxSize: {2} queuelen: {3}; active {4}; pool size: {5}",
                       Thread.CurrentThread.Id, _threadPool.CorePoolSize, _threadPool.MaximumPoolSize, _threadPool.Queue.Size(), _threadPool.ActiveCount, _threadPool.PoolSize);

            _checkIncreaseThreadCount = null;

            if (_threadPool.Queue.IsEmpty || _threadPool.CorePoolSize >= _threadPool.MaximumPoolSize)
            {
                return;
            }

            VerboseLog("{0:000}|increasing core threadpool size from {1}; maxSize: {2} queuelen: {3}; active {4}; pool size: {5}",
                       Thread.CurrentThread.Id, _threadPool.CorePoolSize, _threadPool.MaximumPoolSize, _threadPool.Queue.Size(), _threadPool.ActiveCount, _threadPool.PoolSize);

            _threadPool.CorePoolSize += 1;

            ScheduleCheckThreadCount();
        }