コード例 #1
0
 public void AddTimer(TimerEntry timer)
 {
     this.AddMessage(delegate
     {
         this.m_timers.Add(timer);
     });
 }
コード例 #2
0
 public void RemoveTimer(TimerEntry timer)
 {
     this.AddMessage(delegate
     {
         this.m_timers.Remove(timer);
     });
 }
コード例 #3
0
        public void SaveTimerEntry()
        {
            TimerEntry entry;

            var getTask = service.GetTimerEntryAsync();

            getTask.Wait();
            entry = getTask.Result;

            if (entry == null)
            {
                entry = new TimerEntry {
                    Date = DateTime.Now.AddHours(-1)
                };
            }

            try {
                var task = service.SaveTimerEntryAsync(entry, CancellationToken.None);

                task.Wait();

                Assert.That(task.Result, Is.EqualTo(1));
            } finally {
                var deleteTask = service.DeleteTimerEntryAsync(entry, CancellationToken.None);

                deleteTask.Wait();
            }
        }
コード例 #4
0
    void doTransmit(Bundle bundle)
    {
        Debug.Assert(transmission == null);
        Debug.Assert(IsAvailable);
        uint totalSize = calculateTotalSize(bundle);

        transmittedData += totalSize;
        double transmissionTime = totalSize / link.Speed;

        transmission = Timer.Schedule(Timer.CurrentTime + transmissionTime, onTransmissionFinished, null);
        double totalDelay = transmissionTime + link.GetDelay();

        if (dataDiscarded(totalSize) || link.IsBroken)
        {
            TimerEntry entry = Timer.Schedule(Timer.CurrentTime + totalDelay, onNoDelivery, bundle);
            bool       added = toNotBeDelivered.Add(entry);
            Debug.Assert(added);
        }
        else
        {
            TimerEntry entry = Timer.Schedule(Timer.CurrentTime + totalDelay, onDelivery, bundle);
            bool       added = toBeDelivered.Add(entry);
            if (!added)
            {
                bool found = toBeDelivered.Find(ref entry);
                Debug.Assert(false);
            }
            Debug.Assert(added);
        }
    }
コード例 #5
0
        /// <summary>
        /// Initializes this AreaAura with the given controller.
        /// If no controller is given, the AreaAura controls timing and disposal itself.
        /// </summary>
        /// <param name="controller">A controller controls timing and disposal of this AreaAura</param>
        /// <param name="noTimeout">whether the Aura should not expire (ignore the Spell's duration).</param>
        public void Start(ITickTimer controller, bool noTimeout)
        {
            if (this.m_IsActivated)
            {
                return;
            }
            if ((double)this.m_radius == 0.0)
            {
                this.m_radius = 5f;
            }
            this.m_controller = controller;
            if (this.m_controller == null || this.m_controller.MaxTicks == 1)
            {
                this.m_timer = this.m_params == null
                    ? new TimerEntry(AreaAura.DefaultAmplitude, AreaAura.DefaultAmplitude,
                                     new Action <int>(this.RevalidateTargetsAndApply))
                    : new TimerEntry(this.m_params.StartDelay,
                                     this.m_params.Amplitude != 0 ? this.m_params.Amplitude : AreaAura.DefaultAmplitude,
                                     new Action <int>(this.RevalidateTargetsAndApply));
            }
            if (noTimeout)
            {
                this.m_duration = int.MaxValue;
            }
            else
            {
                this.m_duration = this.m_spell.GetDuration(this.m_CasterReference);
                if (this.m_duration < 1)
                {
                    this.m_duration = int.MaxValue;
                }
            }

            this.IsActivated = true;
        }
コード例 #6
0
    void onRouteTimeout(TimerEntry entry)
    {
        Node destination = (Node)entry.UserData;
        bool removed     = routingTable.Remove(destination);

        Debug.Assert(removed);
    }
コード例 #7
0
ファイル: BundleInstance.cs プロジェクト: szymonwieloch/DTN
//CALLBACKS
    void onBundleLifeTimeEnd(TimerEntry entry)
    {
        Bundle bundle  = (Bundle)entry.UserData;
        bool   removed = handledBundles.Remove(bundle);

        Debug.Assert(removed);
    }
コード例 #8
0
ファイル: AreaAura.cs プロジェクト: 0xFh/Asda2-Project
        /// <summary>
        /// Initializes this AreaAura with the given controller.
        /// If no controller is given, the AreaAura controls timing and disposal itself.
        /// </summary>
        /// <param name="controller">A controller controls timing and disposal of this AreaAura</param>
        /// <param name="noTimeout">whether the Aura should not expire (ignore the Spell's duration).</param>
        public void Start(ITickTimer controller, bool noTimeout)
        {
            if (m_IsActivated)
            {
                return;
            }
            if (m_radius == 0.0)
            {
                m_radius = 5f;
            }
            m_controller = controller;
            if (m_controller == null || m_controller.MaxTicks == 1)
            {
                m_timer = m_params == null
          ? new TimerEntry(DefaultAmplitude, DefaultAmplitude,
                           RevalidateTargetsAndApply)
          : new TimerEntry(m_params.StartDelay,
                           m_params.Amplitude != 0 ? m_params.Amplitude : DefaultAmplitude,
                           RevalidateTargetsAndApply);
            }
            if (noTimeout)
            {
                m_duration = int.MaxValue;
            }
            else
            {
                m_duration = m_spell.GetDuration(m_CasterReference);
                if (m_duration < 1)
                {
                    m_duration = int.MaxValue;
                }
            }

            IsActivated = true;
        }
コード例 #9
0
ファイル: TcpLinkProtocol.cs プロジェクト: szymonwieloch/DTN
 void onConfirmation(TimerEntry entry)
 {
     Debug.Assert(state == State.Confirming);
     Debug.Assert(timeout == entry);
     timeout = null;
     Logger.Log(this, "Confirmed {0} bytes", sendingData);
     statConfirmedData += sendingData;
     sentData          += sendingData;
     sendingData        = 0;
     //remove stored bundles
     while (bundles.Count > 0)
     {
         if (bundles[0].Size <= sentData)
         {
             Bundle bundle = bundles.Dequeue();
             sentData      -= bundle.Size;
             deliveredData -= bundle.Size;
         }
         else
         {
             break;
         }
     }
     increaseWindow();
     sendWindow();
 }
コード例 #10
0
ファイル: Gatherer.cs プロジェクト: szymonwieloch/DTN
 void gatherStatistics(TimerEntry entry)
 {
     if (statisticsGenerators == null)
     {
         //gather all statistics
         foreach (Identificable identificable in Network.Identificables)
         {
             if (identificable is StatisticsGenerator)
             {
                 writeEverything((StatisticsGenerator)identificable);
             }
         }
     }
     else
     {
         foreach (StatisticsGeneratorData data in statisticsGenerators)
         {
             if (data.Names == null)
             {
                 writeEverything(data.Generator);
             }
             else
             {
                 Dictionary <string, object> statistics = data.Generator.GetStatistics();
                 foreach (string name in data.Names)
                 {
                     write(data.Generator, name, statistics[name]);
                 }
             }
         }
     }
     Timer.Schedule(Timer.CurrentTime + this.randomGenerator.GetRandom(), gatherStatistics, null);
 }
コード例 #11
0
        protected bool Start()
        {
            try
            {
                IsCached = AuthServerConfiguration.CacheAccounts;

                //I would have liked this to be a readonly field but it must be
                //initialised here otherwise in the ctor AccountReloadIntervalMs
                //wont have been init'd which would mean we cant customise the timer easily
                _accountsReloadTimer = new TimerEntry(0, AccountReloadIntervalMs, delay =>
                {
                    if (Instance.IsCached)
                    {
                        Instance.Resync();
                    }
                });
                _accountsReloadTimer.Start();
                AuthenticationServer.IOQueue.RegisterUpdatable(_accountsReloadTimer);

                if (Count == 0)
                {
                    log.Info("Detected empty Account-database.");
                    //if (!DoesAccountExist("Administrator"))
                    //{
                    //    CreateAccount("Administrator", DefaultAdminPW, null, RoleGroupInfo.HighestRole.Name, ClientId.Wotlk);
                    //    log.Warn("Created new Account \"Administrator\" with same password.");
                    //}
                }
            }
            catch (Exception e)
            {
                AuthDBMgr.OnDBError(e);
            }
            return(true);
        }
コード例 #12
0
ファイル: RoutingProtocol.cs プロジェクト: szymonwieloch/DTN
    //CALLBACKS
    void onBundleLifeTimeEnd(TimerEntry entry)
    {
        Bundle bundle  = (Bundle)entry.UserData;
        bool   removed = broadcasted.Remove(bundle);

        Debug.Assert(removed);
    }
コード例 #13
0
    void onPendingRequestTimeout(TimerEntry entry)
    {
        Node destination = (Node)entry.UserData;
        bool removed     = pendingRequests.Remove(destination);

        Debug.Assert(removed);
    }
コード例 #14
0
ファイル: TcpLinkProtocol.cs プロジェクト: szymonwieloch/DTN
 void onNoDelivery(TimerEntry entry)
 {
     Debug.Assert(state == State.NotDelivering);
     Debug.Assert(timeout == entry);
     timeout = null;
     sendNoConfirmation();
 }
コード例 #15
0
ファイル: TcpLinkProtocol.cs プロジェクト: szymonwieloch/DTN
 void onNoConfirmation(TimerEntry entry)
 {
     Debug.Assert(state == State.NotConfirming);
     Debug.Assert(timeout == entry);
     timeout = null;
     decreaseWindow();
     sendWindow();
 }
コード例 #16
0
        public ActionResult AddTimerEntry(TimerEntry data, int DietID)
        {
            EntryManager entry = new EntryManager(_context);

            data.ID = 0;
            entry.AddEntry(data, DietID);
            return(RedirectToAction("Show_Entry", new { ID = DietID }));
        }
コード例 #17
0
 public ActionResult Edit_Timer_Entry(TimerEntry data, int DietID)
 {
     _context.TimerEntries.Find(data.ID).Name        = data.Name;
     _context.TimerEntries.Find(data.ID).Description = data.Description;
     _context.TimerEntries.Find(data.ID).EndTime     = data.EndTime;
     _context.SaveChanges();
     return(RedirectToAction("Show_Entry", new { ID = DietID }));
 }
コード例 #18
0
ファイル: TcpLinkProtocol.cs プロジェクト: szymonwieloch/DTN
 void onHandshake(TimerEntry entry)
 {
     Debug.Assert(state == State.Handshake);
     Logger.Log(this, "Handshake done");
     state   = State.Idle;
     timeout = null;
     onLinkFree();
 }
コード例 #19
0
    void onNoConfirmation(TimerEntry entry)
    {
        bool   removed = noConfirmations.Remove(entry);
        Bundle bundle  = (Bundle)entry.UserData;

        transmit(bundle);
        ++retransmissions;
    }
コード例 #20
0
 //HELPERS
 void onFree(TimerEntry entry)
 {
     free = null;
     if (IsAvailable)
     {
         onLinkFree();
     }
 }
コード例 #21
0
//CALLBACKS
    void onBundleDelayTooBig(TimerEntry entry)
    {
        ++routesNotFound;
        Bundle bundle  = (Bundle)entry.UserData;
        bool   removed = delayedBundles.Remove(bundle);

        Debug.Assert(removed);
    }
コード例 #22
0
ファイル: GameObject.cs プロジェクト: NecroSharper/WCell
 void StopDecayTimer()
 {
     if (m_decayTimer != null)
     {
         m_decayTimer.Stop();
         m_decayTimer = null;
     }
 }
コード例 #23
0
ファイル: TcpLinkProtocol.cs プロジェクト: szymonwieloch/DTN
 //CALLBACKS
 void onDelivery(TimerEntry entry)
 {
     Debug.Assert(state == State.Delivering);
     Debug.Assert(timeout == entry);
     timeout            = null;
     statDeliveredData += sendingData;
     passBundles();
     sendConfirmation();
 }
コード例 #24
0
 private void StopDecayTimer()
 {
     if (m_decayTimer == null)
     {
         return;
     }
     m_decayTimer.Stop();
     m_decayTimer = null;
 }
コード例 #25
0
 /// <summary>
 /// Cancels scheduled event. 
 /// </summary>
 /// <param name="entry">Object returned from Schedule method as event ID.</param>
 public static void Cancel(TimerEntry entry)
 {
     //entries after end of simulation
     if (entry.Time > simulationTime)
         return;
     TimerEntryImplementation implementation = (TimerEntryImplementation)entry;
     TimerEntryImplementation deleted = events.Delete(implementation.Handle);
     Debug.Assert(implementation == deleted);
 }
コード例 #26
0
 private void StopDecayTimer()
 {
     if (this.m_decayTimer == null)
     {
         return;
     }
     this.m_decayTimer.Stop();
     this.m_decayTimer = (TimerEntry)null;
 }
コード例 #27
0
        /// <summary>
        /// Called when the battle starts (perparation ends now)
        /// </summary>
        protected override void OnStart()
        {
            base.OnStart();
            Characters.SendSystemMessage(DefaultAddonLocalizer.Instance.GetTranslations(AddonMsgKey.ABOnStart));
            _allianceDoor.State = GameObjectState.Disabled;
            _hordeDoor.State    = GameObjectState.Disabled;

            timerUpdate = CallPeriodically(BattleUpdateDelayMillis, Update);
        }
コード例 #28
0
    void doNotConfirm(Bundle bundle)
    {
        Debug.Assert(IsAvailable);
        double     delay = link.GetDelay() + confirmationTransmitTime;
        TimerEntry entry = Timer.Schedule(Timer.CurrentTime + delay, onNoConfirmation, bundle);
        bool       added = noConfirmations.Add(entry);

        Debug.Assert(added);
    }
コード例 #29
0
    void onArrived(TimerEntry entry)
    {
        bool removed = packets.Remove(entry);

        Debug.Assert(removed);
        Bundle bundle = (Bundle)entry.UserData;

        onBundleArrived(bundle);
    }
コード例 #30
0
    void onNoDelivery(TimerEntry entry)
    {
        bool removed = toNotBeDelivered.Remove(entry);

        Debug.Assert(removed);
        Bundle bundle = (Bundle)entry.UserData;

        notConfirm(bundle);
    }
コード例 #31
0
ファイル: Timer.cs プロジェクト: cartman300/Tetraquark
 public static void Update(float Time)
 {
     InsideUpdate = true;
     var Tmrs = AllTimers.ToArray();
     for (int i = 0; i < Tmrs.Length; i++) {
         CurrentTimer = Tmrs[i];
         if (CurrentTimer.NextTime <= Time) {
             AllTimers.Remove(CurrentTimer);
             CurrentState = CurrentTimer.State;
             CurrentTimer.State = CurrentTimer.T(CurrentTimer.State);
         }
     }
     InsideUpdate = false;
 }
コード例 #32
0
        public void Add(float dur, System.Action callback)
        {
            if (callback == null) throw new System.ArgumentNullException("callback");

            double endTime = _currentTime + dur;
            var entry = new TimerEntry(endTime, callback);

            if(_lst.Count > 0 && endTime < _lst.Last().EndTime)
            {
                for (int i = 0; i < _lst.Count; i++)
                {
                    if (endTime < _lst[i].EndTime)
                    {
                        _lst.Insert(i, entry);
                        return;
                    }
                }
            }

            _lst.Add(entry);
        }