Changeset 3289 for trunk/sources/HeuristicLab.Core/3.3/Engine.cs
- Timestamp:
- 04/09/10 01:15:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Engine.cs
r3288 r3289 30 30 public abstract class Engine : Executable, IEngine { 31 31 [Storable] 32 protected ILog log; 33 public ILog Log { 34 get { return log; } 35 } 36 37 [Storable] 32 38 private Stack<IOperation> executionStack; 33 39 protected Stack<IOperation> ExecutionStack { … … 41 47 protected Engine() 42 48 : base() { 49 log = new Log(); 43 50 executionStack = new Stack<IOperation>(); 51 pausePending = stopPending = false; 52 timer = new System.Timers.Timer(100); 53 timer.AutoReset = true; 54 timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); 55 } 56 [StorableConstructor] 57 protected Engine(bool deserializing) 58 : base(deserializing) { 44 59 pausePending = stopPending = false; 45 60 timer = new System.Timers.Timer(100); … … 51 66 if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState)); 52 67 Engine clone = (Engine)base.Clone(cloner); 68 clone.log = (ILog)cloner.Clone(log); 53 69 IOperation[] contexts = executionStack.ToArray(); 54 70 for (int i = contexts.Length - 1; i >= 0; i--) … … 71 87 OnPrepared(); 72 88 } 89 protected override void OnPrepared() { 90 Log.LogMessage("Engine prepared"); 91 base.OnPrepared(); 92 } 93 73 94 public override void Start() { 74 95 base.Start(); 75 96 ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null); 76 97 } 98 protected override void OnStarted() { 99 Log.LogMessage("Engine started"); 100 base.OnStarted(); 101 } 102 77 103 public override void Pause() { 78 104 base.Pause(); 79 105 pausePending = true; 80 106 } 107 protected override void OnPaused() { 108 Log.LogMessage("Engine paused"); 109 base.OnPaused(); 110 } 111 81 112 public override void Stop() { 82 113 base.Stop(); 83 114 stopPending = true; 84 115 if (ExecutionState == ExecutionState.Paused) OnStopped(); 116 } 117 protected override void OnStopped() { 118 Log.LogMessage("Engine stopped"); 119 base.OnStopped(); 120 } 121 122 protected override void OnExceptionOccurred(Exception exception) { 123 Log.LogException(exception); 124 base.OnExceptionOccurred(exception); 85 125 } 86 126
Note: See TracChangeset
for help on using the changeset viewer.