コード例 #1
0
        public IDisposable RegisterTimer(Grain grain, Func <object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
        {
            var timer = GrainTimer.FromTaskCallback(this.scheduler, this.timerLogger, asyncCallback, state, dueTime, period, activationData: grain?.Data);

            grain?.Data.OnTimerCreated(timer);
            timer.Start();
            return(timer);
        }
コード例 #2
0
ファイル: TimerRegistry.cs プロジェクト: veikkoeeva/orleans
        public IDisposable RegisterTimer(IGrainContext grainContext, Func <object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
        {
            var timer = GrainTimer.FromTaskCallback(this.timerLogger, asyncCallback, state, dueTime, period, grainContext: grainContext);

            grainContext?.GetComponent <IGrainTimerRegistry>().OnTimerCreated(timer);
            timer.Start();
            return(timer);
        }
コード例 #3
0
            public void StopReminder(TraceLogger logger)
            {
                if (Timer != null)
                {
                    Timer.Dispose();
                }

                Timer = null;
            }
コード例 #4
0
            public void StartTimer(OrleansTaskScheduler scheduler, Func <object, Task> asyncCallback, Logger Logger)
            {
                StopReminder(Logger); // just to make sure.
                var dueTimeSpan = CalculateDueTime();

                Timer = GrainTimer.FromTaskCallback(scheduler, asyncCallback, this, dueTimeSpan, period, name: ReminderName);
                if (Logger.IsVerbose)
                {
                    Logger.Verbose("Reminder {0}, Due time{1}", this, dueTimeSpan);
                }
                Timer.Start();
            }
コード例 #5
0
            public void StartTimer(Func <object, Task> asyncCallback, TraceLogger logger)
            {
                StopReminder(logger); // just to make sure.
                var dueTimeSpan = CalculateDueTime();

                Timer = GrainTimer.FromTaskCallback(asyncCallback, this, dueTimeSpan, period, name: ReminderName);
                if (logger.IsVerbose)
                {
                    logger.Verbose("Reminder {0}, Due time{1}", this, dueTimeSpan);
                }
                Timer.Start();
            }
コード例 #6
0
        private void StartTimer()
        {
            if (timer != null)
                timer.Dispose();

            timer = GrainTimer.FromTimerCallback(
                this.RuntimeClient.Scheduler,
                this.OnGossipTimerTick,
                null,
                this.backgroundGossipInterval,
                this.backgroundGossipInterval,
                "MultiCluster.GossipTimer");

            timer.Start();
        }
コード例 #7
0
        protected override async Task StartInBackground()
        {
            await DoInitialReadAndUpdateReminders();

            if (Status == GrainServiceStatus.Booting)
            {
                var random = new SafeRandom();
                listRefreshTimer = GrainTimer.FromTaskCallback(
                    _ => DoInitialReadAndUpdateReminders(),
                    null,
                    random.NextTimeSpan(InitialReadRetryPeriod),
                    InitialReadRetryPeriod,
                    name: "ReminderService.ReminderListInitialRead");
                listRefreshTimer.Start();
            }
        }
コード例 #8
0
        public Task Stop()
        {
            logger.Info(ErrorCode.RS_ServiceStopping, "Stopping reminder system target");
            status = ReminderServiceStatus.Stopped;

            ring.UnSubscribeFromRangeChangeEvents(this);

            if (listRefresher != null)
            {
                listRefresher.Dispose();
                listRefresher = null;
            }
            foreach (LocalReminderData r in localReminders.Values)
            {
                r.StopReminder(logger);
            }

            // for a graceful shutdown, also handover reminder responsibilities to new owner, and update the ReminderTable
            // currently, this is taken care of by periodically reading the reminder table
            return(TaskDone.Done);
        }
コード例 #9
0
 public Task Start()
 {
     requestProcessor = GrainTimer.FromTaskCallback(this.RuntimeClient.Scheduler, this.loggerFactory.CreateLogger <GrainTimer>(), ProcessRequests, null, TimeSpan.FromMilliseconds(0), TimeSpan.FromMilliseconds(10), "TransactionAgent");
     requestProcessor.Start();
     return(Task.CompletedTask);
 }