##// END OF EJS Templates
working on diagnostics
cin -
r194:d45bdf510514 v2
parent child
Show More
@@ -1,195 +1,195
1 using System;
1 using System;
2 using System.Reflection;
2 using System.Reflection;
3 using System.Threading;
3 using System.Threading;
4 using Implab.Parallels;
4 using Implab.Parallels;
5 using Implab.Components;
5 using Implab.Components;
6
6
7 #if MONO
7 #if MONO
8
8
9 using NUnit.Framework;
9 using NUnit.Framework;
10 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
10 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
11 using TestMethodAttribute = NUnit.Framework.TestAttribute;
11 using TestMethodAttribute = NUnit.Framework.TestAttribute;
12 using AssertFailedException = NUnit.Framework.AssertionException;
12 using AssertFailedException = NUnit.Framework.AssertionException;
13 #else
13 #else
14
14
15 using Microsoft.VisualStudio.TestTools.UnitTesting;
15 using Microsoft.VisualStudio.TestTools.UnitTesting;
16
16
17 #endif
17 #endif
18
18
19 namespace Implab.Test {
19 namespace Implab.Test {
20 [TestClass]
20 [TestClass]
21 public class RunnableComponentTests {
21 public class RunnableComponentTests {
22
22
23 static void ShouldThrow(Action action) {
23 static void ShouldThrow(Action action) {
24 try {
24 try {
25 action();
25 action();
26 Assert.Fail();
26 Assert.Fail();
27 } catch (AssertFailedException) {
27 } catch (AssertFailedException) {
28 throw;
28 throw;
29 } catch {
29 } catch {
30 }
30 }
31 }
31 }
32
32
33 class Runnable : RunnableComponent {
33 class Runnable : RunnableComponent {
34 public Runnable(bool initialized) : base(initialized) {
34 public Runnable(bool initialized) : base(initialized) {
35 }
35 }
36
36
37 public Action MockInit {
37 public Action MockInit {
38 get;
38 get;
39 set;
39 set;
40 }
40 }
41
41
42 public Func<IPromise> MockStart {
42 public Func<IPromise> MockStart {
43 get;
43 get;
44 set;
44 set;
45 }
45 }
46
46
47 public Func<IPromise> MockStop {
47 public Func<IPromise> MockStop {
48 get;
48 get;
49 set;
49 set;
50 }
50 }
51
51
52 protected override IPromise OnStart() {
52 protected override IPromise OnStart() {
53 return MockStart != null ? MockStart() : base.OnStart();
53 return MockStart != null ? MockStart() : base.OnStart();
54 }
54 }
55
55
56 protected override IPromise OnStop() {
56 protected override IPromise OnStop() {
57 return MockStop != null ? MockStop() : base.OnStart();
57 return MockStop != null ? MockStop() : base.OnStart();
58 }
58 }
59
59
60 protected override void OnInitialize() {
60 protected override void OnInitialize() {
61 if (MockInit != null)
61 if (MockInit != null)
62 MockInit();
62 MockInit();
63 }
63 }
64 }
64 }
65
65
66 [TestMethod]
66 [TestMethod]
67 public void NormalFlowTest() {
67 public void NormalFlowTest() {
68 var comp = new Runnable(false);
68 var comp = new Runnable(false);
69
69
70 Assert.AreEqual(ExecutionState.Created, comp.State);
70 Assert.AreEqual(ExecutionState.Created, comp.State);
71
71
72 comp.Init();
72 comp.Init();
73
73
74 Assert.AreEqual(ExecutionState.Ready, comp.State);
74 Assert.AreEqual(ExecutionState.Ready, comp.State);
75
75
76 comp.Start().Join(1000);
76 comp.Start().Join(1000);
77
77
78 Assert.AreEqual(ExecutionState.Running, comp.State);
78 Assert.AreEqual(ExecutionState.Running, comp.State);
79
79
80 comp.Stop().Join(1000);
80 comp.Stop().Join(1000);
81
81
82 Assert.AreEqual(ExecutionState.Disposed, comp.State);
82 Assert.AreEqual(ExecutionState.Disposed, comp.State);
83
83
84 }
84 }
85
85
86 [TestMethod]
86 [TestMethod]
87 public void InitFailTest() {
87 public void InitFailTest() {
88 var comp = new Runnable(false) {
88 var comp = new Runnable(false) {
89 MockInit = () => {
89 MockInit = () => {
90 throw new Exception("BAD");
90 throw new Exception("BAD");
91 }
91 }
92 };
92 };
93
93
94 ShouldThrow(() => comp.Start());
94 ShouldThrow(() => comp.Start());
95 ShouldThrow(() => comp.Stop());
95 ShouldThrow(() => comp.Stop());
96 Assert.AreEqual(ExecutionState.Created, comp.State);
96 Assert.AreEqual(ExecutionState.Created, comp.State);
97
97
98 ShouldThrow(comp.Init);
98 ShouldThrow(comp.Init);
99
99
100 Assert.AreEqual(ExecutionState.Failed, comp.State);
100 Assert.AreEqual(ExecutionState.Failed, comp.State);
101
101
102 ShouldThrow(() => comp.Start());
102 ShouldThrow(() => comp.Start());
103 ShouldThrow(() => comp.Stop());
103 ShouldThrow(() => comp.Stop());
104 Assert.AreEqual(ExecutionState.Failed, comp.State);
104 Assert.AreEqual(ExecutionState.Failed, comp.State);
105
105
106 comp.Dispose();
106 comp.Dispose();
107 Assert.AreEqual(ExecutionState.Disposed, comp.State);
107 Assert.AreEqual(ExecutionState.Disposed, comp.State);
108 }
108 }
109
109
110 [TestMethod]
110 [TestMethod]
111 public void DisposedTest() {
111 public void DisposedTest() {
112
112
113 var comp = new Runnable(false);
113 var comp = new Runnable(false);
114 comp.Dispose();
114 comp.Dispose();
115
115
116 ShouldThrow(() => comp.Start());
116 ShouldThrow(() => comp.Start());
117 ShouldThrow(() => comp.Stop());
117 ShouldThrow(() => comp.Stop());
118 ShouldThrow(comp.Init);
118 ShouldThrow(comp.Init);
119
119
120 Assert.AreEqual(ExecutionState.Disposed, comp.State);
120 Assert.AreEqual(ExecutionState.Disposed, comp.State);
121 }
121 }
122
122
123 [TestMethod]
123 [TestMethod]
124 public void StartCancelTest() {
124 public void StartCancelTest() {
125 var comp = new Runnable(true) {
125 var comp = new Runnable(true) {
126 MockStart = () => PromiseHelper.Sleep(100000, 0)
126 MockStart = () => PromiseHelper.Sleep(100000, 0)
127 };
127 };
128
128
129 var p = comp.Start();
129 var p = comp.Start();
130 Assert.AreEqual(ExecutionState.Starting, comp.State);
130 Assert.AreEqual(ExecutionState.Starting, comp.State);
131 p.Cancel();
131 p.Cancel();
132 ShouldThrow(() => p.Join(1000));
132 ShouldThrow(() => p.Join(1000));
133 Assert.AreEqual(ExecutionState.Failed, comp.State);
133 Assert.AreEqual(ExecutionState.Failed, comp.State);
134
134
135 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
135 Assert.IsTrue(comp.LastError is OperationCanceledException);
136
136
137 comp.Dispose();
137 comp.Dispose();
138 }
138 }
139
139
140 [TestMethod]
140 [TestMethod]
141 public void StartStopTest() {
141 public void StartStopTest() {
142 var stop = new Signal();
142 var stop = new Signal();
143 var comp = new Runnable(true) {
143 var comp = new Runnable(true) {
144 MockStart = () => PromiseHelper.Sleep(100000, 0),
144 MockStart = () => PromiseHelper.Sleep(100000, 0),
145 MockStop = () => AsyncPool.RunThread(stop.Wait)
145 MockStop = () => AsyncPool.RunThread(stop.Wait)
146 };
146 };
147
147
148 var p1 = comp.Start();
148 var p1 = comp.Start();
149 var p2 = comp.Stop();
149 var p2 = comp.Stop();
150 // should enter stopping state
150 // should enter stopping state
151
151
152 ShouldThrow(p1.Join);
152 ShouldThrow(p1.Join);
153 Assert.IsTrue(p1.IsCancelled);
153 Assert.IsTrue(p1.IsCancelled);
154 Assert.AreEqual(ExecutionState.Stopping, comp.State);
154 Assert.AreEqual(ExecutionState.Stopping, comp.State);
155
155
156 stop.Set();
156 stop.Set();
157 p2.Join(1000);
157 p2.Join(1000);
158 Assert.AreEqual(ExecutionState.Disposed, comp.State);
158 Assert.AreEqual(ExecutionState.Disposed, comp.State);
159 }
159 }
160
160
161 [TestMethod]
161 [TestMethod]
162 public void StartStopFailTest() {
162 public void StartStopFailTest() {
163 var comp = new Runnable(true) {
163 var comp = new Runnable(true) {
164 MockStart = () => PromiseHelper.Sleep(100000, 0).Then(null,null,x => { throw new Exception("I'm dead"); })
164 MockStart = () => PromiseHelper.Sleep(100000, 0).Then(null,null,x => { throw new Exception("I'm dead"); })
165 };
165 };
166
166
167 comp.Start();
167 comp.Start();
168 var p = comp.Stop();
168 var p = comp.Stop();
169 // if Start fails to cancel, should fail to stop
169 // if Start fails to cancel, should fail to stop
170 ShouldThrow(() => p.Join(1000));
170 ShouldThrow(() => p.Join(1000));
171 Assert.AreEqual(ExecutionState.Failed, comp.State);
171 Assert.AreEqual(ExecutionState.Failed, comp.State);
172 Assert.IsNotNull(comp.LastError);
172 Assert.IsNotNull(comp.LastError);
173 Assert.AreEqual("I'm dead", comp.LastError.Message);
173 Assert.AreEqual("I'm dead", comp.LastError.Message);
174 }
174 }
175
175
176 [TestMethod]
176 [TestMethod]
177 public void StopCancelTest() {
177 public void StopCancelTest() {
178 var comp = new Runnable(true) {
178 var comp = new Runnable(true) {
179 MockStop = () => PromiseHelper.Sleep(100000, 0)
179 MockStop = () => PromiseHelper.Sleep(100000, 0)
180 };
180 };
181
181
182 comp.Start();
182 comp.Start();
183 var p = comp.Stop();
183 var p = comp.Stop();
184 Assert.AreEqual(ExecutionState.Stopping, comp.State);
184 Assert.AreEqual(ExecutionState.Stopping, comp.State);
185 p.Cancel();
185 p.Cancel();
186 ShouldThrow(() => p.Join(1000));
186 ShouldThrow(() => p.Join(1000));
187 Assert.AreEqual(ExecutionState.Failed, comp.State);
187 Assert.AreEqual(ExecutionState.Failed, comp.State);
188 Assert.IsInstanceOfType(comp.LastError, typeof(OperationCanceledException));
188 Assert.IsTrue(comp.LastError is OperationCanceledException);
189
189
190 comp.Dispose();
190 comp.Dispose();
191 }
191 }
192
192
193 }
193 }
194 }
194 }
195
195
@@ -1,86 +1,86
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using System.Collections.Generic;
3 using Implab.Components;
3 using Implab.Components;
4
4
5 namespace Implab.Diagnostics {
5 namespace Implab.Diagnostics {
6 public abstract class ListenerBase : ServiceLocator, ILogWriter<object>, ILogWriter<TraceEvent> {
6 public abstract class ListenerBase : ServiceLocator, ILogWriter<object>, ILogWriter<TraceEvent> {
7
7
8 readonly Dictionary<object, Action> m_subscriptions = new Dictionary<object, Action>();
8 readonly Dictionary<object, Action> m_subscriptions = new Dictionary<object, Action>();
9
9
10 protected ListenerBase() {
10 protected ListenerBase() {
11 Register(this);
11 Register(this);
12 }
12 }
13
13
14 public void Subscribe(Type eventType) {
14 public void Subscribe(Type eventType) {
15 if (eventType == null)
15 if (eventType == null)
16 throw new ArgumentNullException("eventType");
16 throw new ArgumentNullException("eventType");
17 GetType().GetMethod("Subscribe", new Type[0]).MakeGenericMethod(eventType).Invoke(this, null);
17 GetType().GetMethod("Subscribe", new Type[0]).MakeGenericMethod(eventType).Invoke(this, null);
18 }
18 }
19
19
20 public void Subscribe<TEvent>() {
20 public void Subscribe<TEvent>() {
21 Subscribe<TEvent>(LogChannel<TEvent>.Default);
21 Subscribe<TEvent>(LogChannel<TEvent>.Default);
22 }
22 }
23
23
24 public void Subscribe<TEvent>(LogChannel<TEvent> channel) {
24 public void Subscribe<TEvent>(LogChannel<TEvent> channel) {
25 if (channel == null)
25 if (channel == null)
26 throw new ArgumentNullException("channel");
26 throw new ArgumentNullException("channel");
27
27
28 lock (m_subscriptions) {
28 lock (m_subscriptions) {
29 AssertNotDisposed();
29 AssertNotDisposed();
30 if (m_subscriptions.ContainsKey(channel))
30 if (m_subscriptions.ContainsKey(channel))
31 return;
31 return;
32
32
33 var writer = GetService<ILogWriter<TEvent>>();
33 var writer = GetService<ILogWriter<TEvent>>();
34
34
35 EventHandler<LogEventArgs<TEvent>> handler = (sender, args) => writer.Write(args,args.Value);
35 EventHandler<LogEventArgs<TEvent>> handler = (sender, args) => writer.Write(args,args.Value);
36
36
37 channel.Events += handler;
37 channel.Events += handler;
38
38
39 Action unsubscribe = () => {
39 Action unsubscribe = () => {
40 channel.Events -= handler;
40 channel.Events -= handler;
41 };
41 };
42
42
43 m_subscriptions.Add(channel, unsubscribe);
43 m_subscriptions.Add(channel, unsubscribe);
44 }
44 }
45 }
45 }
46
46
47 public void Unsubscribe<TEvent>(LogChannel<TEvent> channel) {
47 public void Unsubscribe<TEvent>(LogChannel<TEvent> channel) {
48 if (channel == null)
48 if (channel == null)
49 throw new ArgumentNullException("channel");
49 throw new ArgumentNullException("channel");
50
50
51 lock (m_subscriptions) {
51 lock (m_subscriptions) {
52 Action subscription;
52 Action subscription;
53 if (m_subscriptions.TryGetValue(channel, out subscription)) {
53 if (m_subscriptions.TryGetValue(channel, out subscription)) {
54 subscription();
54 subscription();
55 m_subscriptions.Remove(channel);
55 m_subscriptions.Remove(channel);
56 }
56 }
57 }
57 }
58 }
58 }
59
59
60 public void UnsubscribeAll() {
60 public void UnsubscribeAll() {
61 lock (m_subscriptions) {
61 lock (m_subscriptions) {
62 foreach (var subscription in m_subscriptions.Values)
62 foreach (var remove in m_subscriptions.Values)
63 subscription();
63 remove();
64 m_subscriptions.Clear();
64 m_subscriptions.Clear();
65 }
65 }
66 }
66 }
67
67
68 #region ILogWriter implementation
68 #region ILogWriter implementation
69 public abstract void Write(LogEventArgs args, object entry);
69 public abstract void Write(LogEventArgs args, object entry);
70 #endregion
70 #endregion
71
71
72 #region ILogWriter implementation
72 #region ILogWriter implementation
73 public virtual void Write(LogEventArgs args, TraceEvent entry) {
73 public virtual void Write(LogEventArgs args, TraceEvent entry) {
74 Write(args, (object)entry);
74 Write(args, (object)entry);
75 }
75 }
76 #endregion
76 #endregion
77
77
78
78
79 protected override void Dispose(bool disposing) {
79 protected override void Dispose(bool disposing) {
80 base.Dispose(disposing);
80 base.Dispose(disposing);
81 if (disposing) {
81 if (disposing) {
82 UnsubscribeAll();
82 UnsubscribeAll();
83 }
83 }
84 }
84 }
85 }
85 }
86 }
86 }
@@ -1,81 +1,85
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using System.Collections.Generic;
3 using System.Linq;
3 using System.Linq;
4 using System.Text;
4 using System.Text;
5
5
6 namespace Implab.Diagnostics {
6 namespace Implab.Diagnostics {
7 /// <summary>
7 /// <summary>
8 /// Канал, через который публикуются события журнала.
8 /// Канал, через который публикуются события журнала.
9 /// </summary>
9 /// </summary>
10 /// <typeparam name="TEvent">Тип событий в канале</typeparam>
10 /// <typeparam name="TEvent">Тип событий в канале</typeparam>
11 /// <remarks>
11 /// <remarks>
12 /// Событиями журнала могут быть любые типы, например строки, в которых будет передаваться
12 /// Событиями журнала могут быть любые типы, например строки, в которых будет передаваться
13 /// информация, или структуры с набором полей, описывающих важность, текст и другую информацию.
13 /// информация, или структуры с набором полей, описывающих важность, текст и другую информацию.
14 /// </remarks>
14 /// </remarks>
15 public class LogChannel<TEvent> {
15 public class LogChannel<TEvent> {
16 static LogChannel<TEvent> _default = new LogChannel<TEvent>();
16 static LogChannel<TEvent> _default = new LogChannel<TEvent>();
17
17
18 /// <summary>
18 /// <summary>
19 /// Канал по-умолчанию для событий типа <typeparam name="TEvent"/>.
19 /// Канал по-умолчанию для событий типа <typeparam name="TEvent"/>.
20 /// </summary>
20 /// </summary>
21 public static LogChannel<TEvent> Default {
21 public static LogChannel<TEvent> Default {
22 get {
22 get {
23 return _default;
23 return _default;
24 }
24 }
25 }
25 }
26
26
27 /// <summary>
27 /// <summary>
28 /// Событие появление новой записи в журнале, на это событие подписываются слушатели.
28 /// Событие появление новой записи в журнале, на это событие подписываются слушатели.
29 /// </summary>
29 /// </summary>
30 public event EventHandler<LogEventArgs<TEvent>> Events;
30 public event EventHandler<LogEventArgs<TEvent>> Events;
31
31
32 /// <summary>
32 /// <summary>
33 /// Имя канала, полезно для отображения в журнале
33 /// Имя канала, полезно для отображения в журнале
34 /// </summary>
34 /// </summary>
35 public string Name {
35 public string Name {
36 get;
36 get;
37 private set;
37 private set;
38 }
38 }
39
39
40 /// <summary>
40 /// <summary>
41 /// Создает журнал, имя типа событий назначается в качетве имени канала.
41 /// Создает журнал, имя типа событий назначается в качетве имени канала.
42 /// </summary>
42 /// </summary>
43 public LogChannel()
43 public LogChannel()
44 : this(null) {
44 : this(null) {
45 }
45 }
46
46
47 /// <summary>
47 /// <summary>
48 /// Содает канал с указанным именем.
48 /// Содает канал с указанным именем.
49 /// </summary>
49 /// </summary>
50 /// <param name="name">Имя канала.</param>
50 /// <param name="name">Имя канала.</param>
51 public LogChannel(string name) {
51 public LogChannel(string name) {
52 if (String.IsNullOrEmpty(name))
52 if (String.IsNullOrEmpty(name))
53 name = typeof(TEvent).Name;
53 name = typeof(TEvent).Name;
54 Name = name;
54 Name = name;
55 }
55 }
56
56
57 /// <summary>
57 /// <summary>
58 /// Отправляет запись журнала через канал подписчикам.
58 /// Отправляет запись журнала через канал подписчикам.
59 /// </summary>
59 /// </summary>
60 /// <param name="data">Запись журнала.</param>
60 /// <param name="data">Запись журнала.</param>
61 /// <remarks>
61 /// <remarks>
62 /// Контекст трассировки от которого рассылается сообщение определяется автоматически из текущего потока.
62 /// Контекст трассировки от которого рассылается сообщение определяется автоматически из текущего потока.
63 /// </remarks>
63 /// </remarks>
64 public void LogEvent(TEvent data) {
64 public void LogEvent(TEvent data) {
65 var t = Events;
65 var t = Events;
66 if (t != null) {
66 if (t != null) {
67 var traceContext = TraceContext.Instance;
67 var traceContext = TraceContext.Instance;
68 t(
68 t(
69 this,
69 this,
70 new LogEventArgs<TEvent>(
70 new LogEventArgs<TEvent>(
71 data,
71 data,
72 Name,
72 this,
73 traceContext.ThreadId,
73 traceContext.ThreadId,
74 traceContext.CurrentOperation,
74 traceContext.CurrentOperation,
75 traceContext.CurrentOperation.Duration
75 traceContext.CurrentOperation.Duration
76 )
76 )
77 );
77 );
78 }
78 }
79 }
79 }
80
81 public override string ToString() {
82 return Name;
80 }
83 }
81 }
84 }
85 }
@@ -1,29 +1,29
1 using System;
1 using System;
2
2
3 namespace Implab.Diagnostics {
3 namespace Implab.Diagnostics {
4 public class LogEventArgs : EventArgs {
4 public class LogEventArgs : EventArgs {
5 public string ChannelName {
5 public object Channel {
6 get;
6 get;
7 private set;
7 private set;
8 }
8 }
9 public int ThreadId {
9 public int ThreadId {
10 get;
10 get;
11 private set;
11 private set;
12 }
12 }
13 public LogicalOperation Operation {
13 public LogicalOperation Operation {
14 get;
14 get;
15 private set;
15 private set;
16 }
16 }
17 public int OperationTimeOffset {
17 public int OperationTimeOffset {
18 get;
18 get;
19 private set;
19 private set;
20 }
20 }
21 public LogEventArgs(string channelName, int threadId, LogicalOperation operation, int timeOffset) {
21 public LogEventArgs(object channel, int threadId, LogicalOperation operation, int timeOffset) {
22 ChannelName = channelName;
22 Channel = channel;
23 ThreadId = threadId;
23 ThreadId = threadId;
24 Operation = operation;
24 Operation = operation;
25 OperationTimeOffset = timeOffset;
25 OperationTimeOffset = timeOffset;
26 }
26 }
27 }
27 }
28 }
28 }
29
29
@@ -1,13 +1,13
1 namespace Implab.Diagnostics {
1 namespace Implab.Diagnostics {
2 public class LogEventArgs<TEvent> : LogEventArgs {
2 public class LogEventArgs<TEvent> : LogEventArgs {
3 public TEvent Value {
3 public TEvent Value {
4 get;
4 get;
5 private set;
5 private set;
6 }
6 }
7
7
8 public LogEventArgs(TEvent value,string channelName, int threadId, LogicalOperation operation, int timeOffset) : base(channelName, threadId, operation, timeOffset) {
8 public LogEventArgs(TEvent value,object channel, int threadId, LogicalOperation operation, int timeOffset) : base(channel, threadId, operation, timeOffset) {
9 Value = value;
9 Value = value;
10 }
10 }
11 }
11 }
12 }
12 }
13
13
@@ -1,46 +1,46
1 using System;
1 using System;
2 using System.IO;
2 using System.IO;
3 using System.Text;
3 using System.Text;
4
4
5 namespace Implab.Diagnostics {
5 namespace Implab.Diagnostics {
6 public class TextFileListener: ListenerBase {
6 public class TextFileListener: ListenerBase {
7 readonly TextWriter m_textWriter;
7 readonly TextWriter m_textWriter;
8
8
9 public TextFileListener(string fileName) {
9 public TextFileListener(string fileName) {
10 m_textWriter = File.CreateText(fileName);
10 m_textWriter = File.CreateText(fileName);
11
11
12 m_textWriter.WriteLine("LOG {0}", DateTime.Now);
12 m_textWriter.WriteLine("LOG {0}", DateTime.Now);
13 }
13 }
14
14
15 #region implemented abstract members of ListenerBase
15 #region implemented abstract members of ListenerBase
16
16
17 public override void Write(LogEventArgs args, object entry) {
17 public override void Write(LogEventArgs args, object entry) {
18 var msg = new StringBuilder();
18 var msg = new StringBuilder();
19 for (int i = 0; i < args.Operation.Level; i++)
19 for (int i = 0; i < args.Operation.Level; i++)
20 msg.Append(" ");
20 msg.Append(" ");
21 msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.ChannelName, entry);
21 msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, args.Channel, entry);
22
22
23 lock (m_textWriter) {
23 lock (m_textWriter) {
24 if (!IsDisposed) {
24 if (!IsDisposed) {
25 // тут гарантировано еще не освобожден m_textWriter
25 // тут гарантировано еще не освобожден m_textWriter
26 m_textWriter.WriteLine(msg);
26 m_textWriter.WriteLine(msg);
27 m_textWriter.Flush();
27 m_textWriter.Flush();
28 }
28 }
29 }
29 }
30 }
30 }
31
31
32 #endregion
32 #endregion
33
33
34 protected override void Dispose(bool disposing) {
34 protected override void Dispose(bool disposing) {
35 base.Dispose(disposing);
35 base.Dispose(disposing);
36 if (disposing) {
36 if (disposing) {
37 // IsDisposed = true
37 // IsDisposed = true
38 lock (m_textWriter) {
38 lock (m_textWriter) {
39 Safe.Dispose(m_textWriter);
39 Safe.Dispose(m_textWriter);
40 }
40 }
41 }
41 }
42 }
42 }
43
43
44
44
45 }
45 }
46 }
46 }
@@ -1,276 +1,275
1 <?xml version="1.0" encoding="utf-8"?>
1 <?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
6 <ProjectGuid>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</ProjectGuid>
7 <OutputType>Library</OutputType>
7 <OutputType>Library</OutputType>
8 <RootNamespace>Implab</RootNamespace>
8 <RootNamespace>Implab</RootNamespace>
9 <AssemblyName>Implab</AssemblyName>
9 <AssemblyName>Implab</AssemblyName>
10 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11 <ReleaseVersion>0.2</ReleaseVersion>
11 <ReleaseVersion>0.2</ReleaseVersion>
12 <ProductVersion>8.0.30703</ProductVersion>
12 <ProductVersion>8.0.30703</ProductVersion>
13 <SchemaVersion>2.0</SchemaVersion>
13 <SchemaVersion>2.0</SchemaVersion>
14 </PropertyGroup>
14 </PropertyGroup>
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 <DebugSymbols>true</DebugSymbols>
16 <DebugSymbols>true</DebugSymbols>
17 <DebugType>full</DebugType>
17 <DebugType>full</DebugType>
18 <Optimize>false</Optimize>
18 <Optimize>false</Optimize>
19 <OutputPath>bin\Debug</OutputPath>
19 <OutputPath>bin\Debug</OutputPath>
20 <DefineConstants>TRACE;DEBUG;</DefineConstants>
20 <DefineConstants>TRACE;DEBUG;</DefineConstants>
21 <ErrorReport>prompt</ErrorReport>
21 <ErrorReport>prompt</ErrorReport>
22 <WarningLevel>4</WarningLevel>
22 <WarningLevel>4</WarningLevel>
23 <ConsolePause>false</ConsolePause>
23 <ConsolePause>false</ConsolePause>
24 <RunCodeAnalysis>true</RunCodeAnalysis>
24 <RunCodeAnalysis>true</RunCodeAnalysis>
25 </PropertyGroup>
25 </PropertyGroup>
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27 <DebugType>full</DebugType>
27 <DebugType>full</DebugType>
28 <Optimize>true</Optimize>
28 <Optimize>true</Optimize>
29 <OutputPath>bin\Release</OutputPath>
29 <OutputPath>bin\Release</OutputPath>
30 <ErrorReport>prompt</ErrorReport>
30 <ErrorReport>prompt</ErrorReport>
31 <WarningLevel>4</WarningLevel>
31 <WarningLevel>4</WarningLevel>
32 <ConsolePause>false</ConsolePause>
32 <ConsolePause>false</ConsolePause>
33 </PropertyGroup>
33 </PropertyGroup>
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
35 <DebugSymbols>true</DebugSymbols>
35 <DebugSymbols>true</DebugSymbols>
36 <DebugType>full</DebugType>
36 <DebugType>full</DebugType>
37 <Optimize>false</Optimize>
37 <Optimize>false</Optimize>
38 <OutputPath>bin\Debug</OutputPath>
38 <OutputPath>bin\Debug</OutputPath>
39 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
39 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
40 <ErrorReport>prompt</ErrorReport>
40 <ErrorReport>prompt</ErrorReport>
41 <WarningLevel>4</WarningLevel>
41 <WarningLevel>4</WarningLevel>
42 <RunCodeAnalysis>true</RunCodeAnalysis>
42 <RunCodeAnalysis>true</RunCodeAnalysis>
43 <ConsolePause>false</ConsolePause>
43 <ConsolePause>false</ConsolePause>
44 </PropertyGroup>
44 </PropertyGroup>
45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
46 <Optimize>true</Optimize>
46 <Optimize>true</Optimize>
47 <OutputPath>bin\Release</OutputPath>
47 <OutputPath>bin\Release</OutputPath>
48 <ErrorReport>prompt</ErrorReport>
48 <ErrorReport>prompt</ErrorReport>
49 <WarningLevel>4</WarningLevel>
49 <WarningLevel>4</WarningLevel>
50 <ConsolePause>false</ConsolePause>
50 <ConsolePause>false</ConsolePause>
51 <DefineConstants>NET_4_5</DefineConstants>
51 <DefineConstants>NET_4_5</DefineConstants>
52 </PropertyGroup>
52 </PropertyGroup>
53 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
53 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
54 <DebugSymbols>true</DebugSymbols>
54 <DebugSymbols>true</DebugSymbols>
55 <DebugType>full</DebugType>
55 <DebugType>full</DebugType>
56 <Optimize>false</Optimize>
56 <Optimize>false</Optimize>
57 <OutputPath>bin\Debug</OutputPath>
57 <OutputPath>bin\Debug</OutputPath>
58 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
58 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
59 <ErrorReport>prompt</ErrorReport>
59 <ErrorReport>prompt</ErrorReport>
60 <WarningLevel>4</WarningLevel>
60 <WarningLevel>4</WarningLevel>
61 <RunCodeAnalysis>true</RunCodeAnalysis>
61 <RunCodeAnalysis>true</RunCodeAnalysis>
62 <ConsolePause>false</ConsolePause>
62 <ConsolePause>false</ConsolePause>
63 </PropertyGroup>
63 </PropertyGroup>
64 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
64 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
65 <Optimize>true</Optimize>
65 <Optimize>true</Optimize>
66 <OutputPath>bin\Release</OutputPath>
66 <OutputPath>bin\Release</OutputPath>
67 <DefineConstants>NET_4_5;MONO;</DefineConstants>
67 <DefineConstants>NET_4_5;MONO;</DefineConstants>
68 <ErrorReport>prompt</ErrorReport>
68 <ErrorReport>prompt</ErrorReport>
69 <WarningLevel>4</WarningLevel>
69 <WarningLevel>4</WarningLevel>
70 <ConsolePause>false</ConsolePause>
70 <ConsolePause>false</ConsolePause>
71 </PropertyGroup>
71 </PropertyGroup>
72 <ItemGroup>
72 <ItemGroup>
73 <Reference Include="System" />
73 <Reference Include="System" />
74 <Reference Include="System.Xml" />
74 <Reference Include="System.Xml" />
75 <Reference Include="mscorlib" />
75 <Reference Include="mscorlib" />
76 </ItemGroup>
76 </ItemGroup>
77 <ItemGroup>
77 <ItemGroup>
78 <Compile Include="CustomEqualityComparer.cs" />
78 <Compile Include="CustomEqualityComparer.cs" />
79 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
79 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
80 <Compile Include="Diagnostics\EventText.cs" />
81 <Compile Include="Diagnostics\LogChannel.cs" />
80 <Compile Include="Diagnostics\LogChannel.cs" />
82 <Compile Include="Diagnostics\LogicalOperation.cs" />
81 <Compile Include="Diagnostics\LogicalOperation.cs" />
83 <Compile Include="Diagnostics\TextFileListener.cs" />
82 <Compile Include="Diagnostics\TextFileListener.cs" />
84 <Compile Include="Diagnostics\TraceLog.cs" />
83 <Compile Include="Diagnostics\TraceLog.cs" />
85 <Compile Include="Diagnostics\TraceEvent.cs" />
84 <Compile Include="Diagnostics\TraceEvent.cs" />
86 <Compile Include="Diagnostics\TraceEventType.cs" />
85 <Compile Include="Diagnostics\TraceEventType.cs" />
87 <Compile Include="ICancellable.cs" />
86 <Compile Include="ICancellable.cs" />
88 <Compile Include="IProgressHandler.cs" />
87 <Compile Include="IProgressHandler.cs" />
89 <Compile Include="IProgressNotifier.cs" />
88 <Compile Include="IProgressNotifier.cs" />
90 <Compile Include="IPromiseT.cs" />
89 <Compile Include="IPromiseT.cs" />
91 <Compile Include="IPromise.cs" />
90 <Compile Include="IPromise.cs" />
92 <Compile Include="IServiceLocator.cs" />
91 <Compile Include="IServiceLocator.cs" />
93 <Compile Include="ITaskController.cs" />
92 <Compile Include="ITaskController.cs" />
94 <Compile Include="Parallels\DispatchPool.cs" />
93 <Compile Include="Parallels\DispatchPool.cs" />
95 <Compile Include="Parallels\ArrayTraits.cs" />
94 <Compile Include="Parallels\ArrayTraits.cs" />
96 <Compile Include="Parallels\MTQueue.cs" />
95 <Compile Include="Parallels\MTQueue.cs" />
97 <Compile Include="Parallels\WorkerPool.cs" />
96 <Compile Include="Parallels\WorkerPool.cs" />
98 <Compile Include="ProgressInitEventArgs.cs" />
97 <Compile Include="ProgressInitEventArgs.cs" />
99 <Compile Include="Properties\AssemblyInfo.cs" />
98 <Compile Include="Properties\AssemblyInfo.cs" />
100 <Compile Include="Parallels\AsyncPool.cs" />
99 <Compile Include="Parallels\AsyncPool.cs" />
101 <Compile Include="Safe.cs" />
100 <Compile Include="Safe.cs" />
102 <Compile Include="ValueEventArgs.cs" />
101 <Compile Include="ValueEventArgs.cs" />
103 <Compile Include="PromiseExtensions.cs" />
102 <Compile Include="PromiseExtensions.cs" />
104 <Compile Include="SyncContextPromise.cs" />
103 <Compile Include="SyncContextPromise.cs" />
105 <Compile Include="Diagnostics\OperationContext.cs" />
104 <Compile Include="Diagnostics\OperationContext.cs" />
106 <Compile Include="Diagnostics\TraceContext.cs" />
105 <Compile Include="Diagnostics\TraceContext.cs" />
107 <Compile Include="Diagnostics\LogEventArgs.cs" />
106 <Compile Include="Diagnostics\LogEventArgs.cs" />
108 <Compile Include="Diagnostics\LogEventArgsT.cs" />
107 <Compile Include="Diagnostics\LogEventArgsT.cs" />
109 <Compile Include="Diagnostics\Extensions.cs" />
108 <Compile Include="Diagnostics\Extensions.cs" />
110 <Compile Include="PromiseEventType.cs" />
109 <Compile Include="PromiseEventType.cs" />
111 <Compile Include="Parallels\AsyncQueue.cs" />
110 <Compile Include="Parallels\AsyncQueue.cs" />
112 <Compile Include="PromiseT.cs" />
111 <Compile Include="PromiseT.cs" />
113 <Compile Include="IDeferred.cs" />
112 <Compile Include="IDeferred.cs" />
114 <Compile Include="IDeferredT.cs" />
113 <Compile Include="IDeferredT.cs" />
115 <Compile Include="Promise.cs" />
114 <Compile Include="Promise.cs" />
116 <Compile Include="PromiseTransientException.cs" />
115 <Compile Include="PromiseTransientException.cs" />
117 <Compile Include="Parallels\Signal.cs" />
116 <Compile Include="Parallels\Signal.cs" />
118 <Compile Include="Parallels\SharedLock.cs" />
117 <Compile Include="Parallels\SharedLock.cs" />
119 <Compile Include="Diagnostics\ILogWriter.cs" />
118 <Compile Include="Diagnostics\ILogWriter.cs" />
120 <Compile Include="Diagnostics\ListenerBase.cs" />
119 <Compile Include="Diagnostics\ListenerBase.cs" />
121 <Compile Include="Parallels\BlockingQueue.cs" />
120 <Compile Include="Parallels\BlockingQueue.cs" />
122 <Compile Include="AbstractEvent.cs" />
121 <Compile Include="AbstractEvent.cs" />
123 <Compile Include="AbstractPromise.cs" />
122 <Compile Include="AbstractPromise.cs" />
124 <Compile Include="AbstractPromiseT.cs" />
123 <Compile Include="AbstractPromiseT.cs" />
125 <Compile Include="FuncTask.cs" />
124 <Compile Include="FuncTask.cs" />
126 <Compile Include="FuncTaskBase.cs" />
125 <Compile Include="FuncTaskBase.cs" />
127 <Compile Include="FuncTaskT.cs" />
126 <Compile Include="FuncTaskT.cs" />
128 <Compile Include="ActionChainTaskBase.cs" />
127 <Compile Include="ActionChainTaskBase.cs" />
129 <Compile Include="ActionChainTask.cs" />
128 <Compile Include="ActionChainTask.cs" />
130 <Compile Include="ActionChainTaskT.cs" />
129 <Compile Include="ActionChainTaskT.cs" />
131 <Compile Include="FuncChainTaskBase.cs" />
130 <Compile Include="FuncChainTaskBase.cs" />
132 <Compile Include="FuncChainTask.cs" />
131 <Compile Include="FuncChainTask.cs" />
133 <Compile Include="FuncChainTaskT.cs" />
132 <Compile Include="FuncChainTaskT.cs" />
134 <Compile Include="ActionTaskBase.cs" />
133 <Compile Include="ActionTaskBase.cs" />
135 <Compile Include="ActionTask.cs" />
134 <Compile Include="ActionTask.cs" />
136 <Compile Include="ActionTaskT.cs" />
135 <Compile Include="ActionTaskT.cs" />
137 <Compile Include="ICancellationToken.cs" />
136 <Compile Include="ICancellationToken.cs" />
138 <Compile Include="SuccessPromise.cs" />
137 <Compile Include="SuccessPromise.cs" />
139 <Compile Include="SuccessPromiseT.cs" />
138 <Compile Include="SuccessPromiseT.cs" />
140 <Compile Include="PromiseAwaiterT.cs" />
139 <Compile Include="PromiseAwaiterT.cs" />
141 <Compile Include="PromiseAwaiter.cs" />
140 <Compile Include="PromiseAwaiter.cs" />
142 <Compile Include="Components\ComponentContainer.cs" />
141 <Compile Include="Components\ComponentContainer.cs" />
143 <Compile Include="Components\Disposable.cs" />
142 <Compile Include="Components\Disposable.cs" />
144 <Compile Include="Components\DisposablePool.cs" />
143 <Compile Include="Components\DisposablePool.cs" />
145 <Compile Include="Components\ObjectPool.cs" />
144 <Compile Include="Components\ObjectPool.cs" />
146 <Compile Include="Components\ServiceLocator.cs" />
145 <Compile Include="Components\ServiceLocator.cs" />
147 <Compile Include="Components\IInitializable.cs" />
146 <Compile Include="Components\IInitializable.cs" />
148 <Compile Include="TaskController.cs" />
147 <Compile Include="TaskController.cs" />
149 <Compile Include="Components\App.cs" />
148 <Compile Include="Components\App.cs" />
150 <Compile Include="Components\IRunnable.cs" />
149 <Compile Include="Components\IRunnable.cs" />
151 <Compile Include="Components\ExecutionState.cs" />
150 <Compile Include="Components\ExecutionState.cs" />
152 <Compile Include="Components\RunnableComponent.cs" />
151 <Compile Include="Components\RunnableComponent.cs" />
153 <Compile Include="Components\IFactory.cs" />
152 <Compile Include="Components\IFactory.cs" />
154 <Compile Include="Automaton\IAlphabet.cs" />
153 <Compile Include="Automaton\IAlphabet.cs" />
155 <Compile Include="Automaton\ParserException.cs" />
154 <Compile Include="Automaton\ParserException.cs" />
156 <Compile Include="Automaton\IndexedAlphabetBase.cs" />
155 <Compile Include="Automaton\IndexedAlphabetBase.cs" />
157 <Compile Include="Automaton\IAlphabetBuilder.cs" />
156 <Compile Include="Automaton\IAlphabetBuilder.cs" />
158 <Compile Include="Automaton\RegularExpressions\AltToken.cs" />
157 <Compile Include="Automaton\RegularExpressions\AltToken.cs" />
159 <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" />
158 <Compile Include="Automaton\RegularExpressions\BinaryToken.cs" />
160 <Compile Include="Automaton\RegularExpressions\CatToken.cs" />
159 <Compile Include="Automaton\RegularExpressions\CatToken.cs" />
161 <Compile Include="Automaton\RegularExpressions\StarToken.cs" />
160 <Compile Include="Automaton\RegularExpressions\StarToken.cs" />
162 <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" />
161 <Compile Include="Automaton\RegularExpressions\SymbolToken.cs" />
163 <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" />
162 <Compile Include="Automaton\RegularExpressions\EmptyToken.cs" />
164 <Compile Include="Automaton\RegularExpressions\Token.cs" />
163 <Compile Include="Automaton\RegularExpressions\Token.cs" />
165 <Compile Include="Automaton\RegularExpressions\IVisitor.cs" />
164 <Compile Include="Automaton\RegularExpressions\IVisitor.cs" />
166 <Compile Include="Automaton\AutomatonTransition.cs" />
165 <Compile Include="Automaton\AutomatonTransition.cs" />
167 <Compile Include="Formats\JSON\JSONElementContext.cs" />
166 <Compile Include="Formats\JSON\JSONElementContext.cs" />
168 <Compile Include="Formats\JSON\JSONElementType.cs" />
167 <Compile Include="Formats\JSON\JSONElementType.cs" />
169 <Compile Include="Formats\JSON\JSONGrammar.cs" />
168 <Compile Include="Formats\JSON\JSONGrammar.cs" />
170 <Compile Include="Formats\JSON\JSONParser.cs" />
169 <Compile Include="Formats\JSON\JSONParser.cs" />
171 <Compile Include="Formats\JSON\JSONScanner.cs" />
170 <Compile Include="Formats\JSON\JSONScanner.cs" />
172 <Compile Include="Formats\JSON\JsonTokenType.cs" />
171 <Compile Include="Formats\JSON\JsonTokenType.cs" />
173 <Compile Include="Formats\JSON\JSONWriter.cs" />
172 <Compile Include="Formats\JSON\JSONWriter.cs" />
174 <Compile Include="Formats\JSON\JSONXmlReader.cs" />
173 <Compile Include="Formats\JSON\JSONXmlReader.cs" />
175 <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" />
174 <Compile Include="Formats\JSON\JSONXmlReaderOptions.cs" />
176 <Compile Include="Formats\JSON\StringTranslator.cs" />
175 <Compile Include="Formats\JSON\StringTranslator.cs" />
177 <Compile Include="Automaton\MapAlphabet.cs" />
176 <Compile Include="Automaton\MapAlphabet.cs" />
178 <Compile Include="Formats\CharAlphabet.cs" />
177 <Compile Include="Formats\CharAlphabet.cs" />
179 <Compile Include="Formats\ByteAlphabet.cs" />
178 <Compile Include="Formats\ByteAlphabet.cs" />
180 <Compile Include="Automaton\IDFATable.cs" />
179 <Compile Include="Automaton\IDFATable.cs" />
181 <Compile Include="Automaton\IDFATableBuilder.cs" />
180 <Compile Include="Automaton\IDFATableBuilder.cs" />
182 <Compile Include="Automaton\DFATable.cs" />
181 <Compile Include="Automaton\DFATable.cs" />
183 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitor.cs" />
182 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitor.cs" />
184 <Compile Include="Automaton\RegularExpressions\ITaggedDFABuilder.cs" />
183 <Compile Include="Automaton\RegularExpressions\ITaggedDFABuilder.cs" />
185 <Compile Include="Formats\TextScanner.cs" />
184 <Compile Include="Formats\TextScanner.cs" />
186 <Compile Include="Formats\StringScanner.cs" />
185 <Compile Include="Formats\StringScanner.cs" />
187 <Compile Include="Formats\ReaderScanner.cs" />
186 <Compile Include="Formats\ReaderScanner.cs" />
188 <Compile Include="Formats\ScannerContext.cs" />
187 <Compile Include="Formats\ScannerContext.cs" />
189 <Compile Include="Formats\Grammar.cs" />
188 <Compile Include="Formats\Grammar.cs" />
190 <Compile Include="Automaton\RegularExpressions\EndTokenT.cs" />
189 <Compile Include="Automaton\RegularExpressions\EndTokenT.cs" />
191 <Compile Include="Automaton\RegularExpressions\EndToken.cs" />
190 <Compile Include="Automaton\RegularExpressions\EndToken.cs" />
192 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitorT.cs" />
191 <Compile Include="Automaton\RegularExpressions\RegularExpressionVisitorT.cs" />
193 <Compile Include="Automaton\AutomatonConst.cs" />
192 <Compile Include="Automaton\AutomatonConst.cs" />
194 <Compile Include="Automaton\RegularExpressions\RegularDFA.cs" />
193 <Compile Include="Automaton\RegularExpressions\RegularDFA.cs" />
195 <Compile Include="Components\LazyAndWeak.cs" />
194 <Compile Include="Components\LazyAndWeak.cs" />
196 <Compile Include="AbstractTask.cs" />
195 <Compile Include="AbstractTask.cs" />
197 <Compile Include="AbstractTaskT.cs" />
196 <Compile Include="AbstractTaskT.cs" />
198 </ItemGroup>
197 </ItemGroup>
199 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
198 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
200 <ItemGroup />
199 <ItemGroup />
201 <ProjectExtensions>
200 <ProjectExtensions>
202 <MonoDevelop>
201 <MonoDevelop>
203 <Properties>
202 <Properties>
204 <Policies>
203 <Policies>
205 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
204 <CSharpFormattingPolicy IndentSwitchBody="True" NamespaceBraceStyle="EndOfLine" ClassBraceStyle="EndOfLine" InterfaceBraceStyle="EndOfLine" StructBraceStyle="EndOfLine" EnumBraceStyle="EndOfLine" MethodBraceStyle="EndOfLine" ConstructorBraceStyle="EndOfLine" DestructorBraceStyle="EndOfLine" BeforeMethodDeclarationParentheses="False" BeforeMethodCallParentheses="False" BeforeConstructorDeclarationParentheses="False" NewLineBeforeConstructorInitializerColon="NewLine" NewLineAfterConstructorInitializerColon="SameLine" BeforeIndexerDeclarationBracket="False" BeforeDelegateDeclarationParentheses="False" NewParentheses="False" SpacesBeforeBrackets="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
206 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
205 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
207 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
206 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
208 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
207 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
209 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
208 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
210 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
209 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
211 <NameConventionPolicy>
210 <NameConventionPolicy>
212 <Rules>
211 <Rules>
213 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
212 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
214 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
213 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
215 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
214 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
216 <RequiredPrefixes>
215 <RequiredPrefixes>
217 <String>I</String>
216 <String>I</String>
218 </RequiredPrefixes>
217 </RequiredPrefixes>
219 </NamingRule>
218 </NamingRule>
220 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
219 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
221 <RequiredSuffixes>
220 <RequiredSuffixes>
222 <String>Attribute</String>
221 <String>Attribute</String>
223 </RequiredSuffixes>
222 </RequiredSuffixes>
224 </NamingRule>
223 </NamingRule>
225 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
224 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
226 <RequiredSuffixes>
225 <RequiredSuffixes>
227 <String>EventArgs</String>
226 <String>EventArgs</String>
228 </RequiredSuffixes>
227 </RequiredSuffixes>
229 </NamingRule>
228 </NamingRule>
230 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
229 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
231 <RequiredSuffixes>
230 <RequiredSuffixes>
232 <String>Exception</String>
231 <String>Exception</String>
233 </RequiredSuffixes>
232 </RequiredSuffixes>
234 </NamingRule>
233 </NamingRule>
235 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
234 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
236 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
235 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
237 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
236 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
238 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
237 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
239 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
238 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
240 <RequiredPrefixes>
239 <RequiredPrefixes>
241 <String>m_</String>
240 <String>m_</String>
242 </RequiredPrefixes>
241 </RequiredPrefixes>
243 </NamingRule>
242 </NamingRule>
244 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
243 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
245 <RequiredPrefixes>
244 <RequiredPrefixes>
246 <String>_</String>
245 <String>_</String>
247 </RequiredPrefixes>
246 </RequiredPrefixes>
248 </NamingRule>
247 </NamingRule>
249 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
248 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
250 <RequiredPrefixes>
249 <RequiredPrefixes>
251 <String>m_</String>
250 <String>m_</String>
252 </RequiredPrefixes>
251 </RequiredPrefixes>
253 </NamingRule>
252 </NamingRule>
254 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
253 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
255 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
254 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
256 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
255 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
257 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
256 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
258 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
257 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
259 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
258 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
260 <RequiredPrefixes>
259 <RequiredPrefixes>
261 <String>T</String>
260 <String>T</String>
262 </RequiredPrefixes>
261 </RequiredPrefixes>
263 </NamingRule>
262 </NamingRule>
264 </Rules>
263 </Rules>
265 </NameConventionPolicy>
264 </NameConventionPolicy>
266 </Policies>
265 </Policies>
267 </Properties>
266 </Properties>
268 </MonoDevelop>
267 </MonoDevelop>
269 </ProjectExtensions>
268 </ProjectExtensions>
270 <ItemGroup>
269 <ItemGroup>
271 <Folder Include="Components\" />
270 <Folder Include="Components\" />
272 <Folder Include="Automaton\RegularExpressions\" />
271 <Folder Include="Automaton\RegularExpressions\" />
273 <Folder Include="Formats\" />
272 <Folder Include="Formats\" />
274 <Folder Include="Formats\JSON\" />
273 <Folder Include="Formats\JSON\" />
275 </ItemGroup>
274 </ItemGroup>
276 </Project> No newline at end of file
275 </Project>
@@ -1,45 +1,48
1 using System;
1 using System;
2 using Implab;
2 using Implab;
3 using System.Threading.Tasks;
3 using System.Threading.Tasks;
4 using Implab.Formats.JSON;
4 using Implab.Formats.JSON;
5 using System.IO;
5 using System.IO;
6 using System.Text.Json;
6 using System.Text.Json;
7 using System.Diagnostics;
8 using Implab.Parallels;
9 using System.Threading;
7
10
8 namespace MonoPlay {
11 namespace MonoPlay {
9 class MainClass {
12 class MainClass {
10
13
11
14
12 public static void Main(string[] args) {
15 public static void Main(string[] args) {
13 if (args == null)
16 var pool = new WorkerPool(10);
14 throw new ArgumentNullException("args");
15 int t1, t2;
16
17
17 for (int i = 0; i < 2; i++) {
18 var listerner = new ConsoleTraceListener();
18 t1 = Environment.TickCount;
19 listerner.TraceOutputOptions = TraceOptions.LogicalOperationStack;
19 int elements =0;
20 Trace.Listeners.Add(listerner);
20 using (var reader = new JSONParser(File.OpenText("/home/sergey/temp/citylots.json"))) {
21
21 while (reader.Read())
22 Trace.CorrelationManager.StartLogicalOperation("Main");
22 elements++;
23 }
24
23
25 t2 = Environment.TickCount;
24 var d = pool.Invoke(() => {
26 Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, Elements: {4}",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0), elements );
25 Trace.CorrelationManager.StartLogicalOperation("Worker");
27 }
26 Thread.Sleep(100);
27 Trace.TraceInformation("worker done");
28 Trace.CorrelationManager.StopLogicalOperation();
29 });
28
30
29 Console.WriteLine("Syste.Text.Json");
31 ThreadPool.QueueUserWorkItem((o) => {
30 var paraser = new JsonParser();
32 Trace.CorrelationManager.StartLogicalOperation("Thread");
31 for (int i = 0; i < 2; i++) {
33 Thread.Sleep(100);
32 t1 = Environment.TickCount;
34 Trace.TraceInformation("thread done");
33 using (var reader = File.OpenText("/home/sergey/temp/citylots.json")) {
35 Trace.CorrelationManager.StopLogicalOperation();
34 paraser.Parse(reader);
36 });
35 }
36
37
37 t2 = Environment.TickCount;
38 Trace.TraceInformation("main done");
38 Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, ",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0));
39 Trace.CorrelationManager.StopLogicalOperation();
39 }
40
41 d.Join();
42
40
43
41
44
42 }
45 }
43
46
44 }
47 }
45 }
48 }
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now