public void Dispose() { ActorModel.Assert(ActorModel.Runtime.GetCurrentMachineId().Equals(this.Actor), $"The timer can only be disposed by its owner, which is {this.Actor}." + $"Instead, {ActorModel.Runtime.GetCurrentMachineId()} called Dispose()."); if (ActorModel.ActorMachineMap[this.Actor].RegisteredTimers.Contains(this.Timer)) { ActorModel.Runtime.Log($"<ActorModelLog> Machine '{this.Actor.Name}' is " + $"unregistering timer '{this.Timer.Name}'."); ActorModel.ActorMachineMap[this.Actor].RegisteredTimers.Remove(this.Timer); ActorModel.Runtime.SendEvent(this.Timer, new Halt()); } }
/// <summary> /// Returns an actor handler, for handling reentrant events. /// </summary> /// <param name="machine">MachineId</param> /// <returns>Action</returns> internal static Action <ActorMachine.ActorEvent> GetReentrantActionHandler(MachineId machine) { ActorModel.Assert(ActorModel.ReentrantActors[machine], $"{machine.Name} is not reentrant."); return(ActorModel.ActorMachineMap[machine].ReentrantActionHandler); }