public void AddTimer(TimerEntry timer) { this.AddMessage(delegate { this.m_timers.Add(timer); }); }
public void RemoveTimer(TimerEntry timer) { this.AddMessage(delegate { this.m_timers.Remove(timer); }); }
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(); } }
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); } }
/// <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; }
void onRouteTimeout(TimerEntry entry) { Node destination = (Node)entry.UserData; bool removed = routingTable.Remove(destination); Debug.Assert(removed); }
//CALLBACKS void onBundleLifeTimeEnd(TimerEntry entry) { Bundle bundle = (Bundle)entry.UserData; bool removed = handledBundles.Remove(bundle); Debug.Assert(removed); }
/// <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; }
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(); }
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); }
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); }
//CALLBACKS void onBundleLifeTimeEnd(TimerEntry entry) { Bundle bundle = (Bundle)entry.UserData; bool removed = broadcasted.Remove(bundle); Debug.Assert(removed); }
void onPendingRequestTimeout(TimerEntry entry) { Node destination = (Node)entry.UserData; bool removed = pendingRequests.Remove(destination); Debug.Assert(removed); }
void onNoDelivery(TimerEntry entry) { Debug.Assert(state == State.NotDelivering); Debug.Assert(timeout == entry); timeout = null; sendNoConfirmation(); }
void onNoConfirmation(TimerEntry entry) { Debug.Assert(state == State.NotConfirming); Debug.Assert(timeout == entry); timeout = null; decreaseWindow(); sendWindow(); }
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 })); }
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 })); }
void onHandshake(TimerEntry entry) { Debug.Assert(state == State.Handshake); Logger.Log(this, "Handshake done"); state = State.Idle; timeout = null; onLinkFree(); }
void onNoConfirmation(TimerEntry entry) { bool removed = noConfirmations.Remove(entry); Bundle bundle = (Bundle)entry.UserData; transmit(bundle); ++retransmissions; }
//HELPERS void onFree(TimerEntry entry) { free = null; if (IsAvailable) { onLinkFree(); } }
//CALLBACKS void onBundleDelayTooBig(TimerEntry entry) { ++routesNotFound; Bundle bundle = (Bundle)entry.UserData; bool removed = delayedBundles.Remove(bundle); Debug.Assert(removed); }
void StopDecayTimer() { if (m_decayTimer != null) { m_decayTimer.Stop(); m_decayTimer = null; } }
//CALLBACKS void onDelivery(TimerEntry entry) { Debug.Assert(state == State.Delivering); Debug.Assert(timeout == entry); timeout = null; statDeliveredData += sendingData; passBundles(); sendConfirmation(); }
private void StopDecayTimer() { if (m_decayTimer == null) { return; } m_decayTimer.Stop(); m_decayTimer = null; }
/// <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); }
private void StopDecayTimer() { if (this.m_decayTimer == null) { return; } this.m_decayTimer.Stop(); this.m_decayTimer = (TimerEntry)null; }
/// <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); }
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); }
void onArrived(TimerEntry entry) { bool removed = packets.Remove(entry); Debug.Assert(removed); Bundle bundle = (Bundle)entry.UserData; onBundleArrived(bundle); }
void onNoDelivery(TimerEntry entry) { bool removed = toNotBeDelivered.Remove(entry); Debug.Assert(removed); Bundle bundle = (Bundle)entry.UserData; notConfirm(bundle); }
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; }
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); }