##// END OF EJS Templates
Adde workaround to the behaviour of the logical operations stack in conjuction...
cin -
r255:b00441e04738 v3
parent child
Show More
@@ -0,0 +1,37
1 
2 Microsoft Visual Studio Solution File, Format Version 12.00
3 # Visual Studio 15
4 VisualStudioVersion = 15.0.27428.2005
5 MinimumVisualStudioVersion = 10.0.40219.1
6 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab", "Implab\Implab.csproj", "{FF2052B6-9C8F-4022-A347-F07ABF635885}"
7 EndProject
8 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Implab.Test", "Implab.Test\Implab.Test.csproj", "{6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}"
9 EndProject
10 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Playground", "Implab.Playground\Implab.Playground.csproj", "{100DFEB0-75BE-436F-ADDF-1F46EF433F46}"
11 EndProject
12 Global
13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 Debug|Any CPU = Debug|Any CPU
15 Release|Any CPU = Release|Any CPU
16 EndGlobalSection
17 GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 {FF2052B6-9C8F-4022-A347-F07ABF635885}.Release|Any CPU.Build.0 = Release|Any CPU
22 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 {6CD0DA18-8D9B-4AA8-A3DC-17322E27335E}.Release|Any CPU.Build.0 = Release|Any CPU
26 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 {100DFEB0-75BE-436F-ADDF-1F46EF433F46}.Release|Any CPU.Build.0 = Release|Any CPU
30 EndGlobalSection
31 GlobalSection(SolutionProperties) = preSolution
32 HideSolutionNode = FALSE
33 EndGlobalSection
34 GlobalSection(ExtensibilityGlobals) = postSolution
35 SolutionGuid = {36D837FC-4CDD-4AEA-87BF-F130FEB22E02}
36 EndGlobalSection
37 EndGlobal
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="utf-8"?>
1 <?xml version="1.0" encoding="utf-8"?>
2 <configuration>
2 <configuration>
3 <startup>
3 <startup>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
4 <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
5 </startup>
5 </startup>
6 </configuration>
6 </configuration>
@@ -9,7 +9,7
9 <AppDesignerFolder>Properties</AppDesignerFolder>
9 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <RootNamespace>Implab.Playground</RootNamespace>
10 <RootNamespace>Implab.Playground</RootNamespace>
11 <AssemblyName>Implab.Playground</AssemblyName>
11 <AssemblyName>Implab.Playground</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
13 <FileAlignment>512</FileAlignment>
13 <FileAlignment>512</FileAlignment>
14 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15 <TargetFrameworkProfile />
15 <TargetFrameworkProfile />
@@ -1,4 +1,5
1 using Implab.Formats.Json;
1 using Implab.Diagnostics;
2 using Implab.Formats.Json;
2 using Implab.Parallels;
3 using Implab.Parallels;
3 using Implab.Xml;
4 using Implab.Xml;
4 using System;
5 using System;
@@ -13,80 +14,42 using System.Xml;
13 using System.Xml.Serialization;
14 using System.Xml.Serialization;
14
15
15 namespace Implab.Playground {
16 namespace Implab.Playground {
17 using System.Diagnostics;
18 using System.Runtime.Remoting.Messaging;
19 using static Trace<Program>;
20
16 public class Program {
21 public class Program {
17
22
18 static void EnqueueRange<T>(ConcurrentQueue<T> q, T[] data, int offset, int len) {
23 static void Main(string[] args) {
19 for (var i = offset; i < offset + len; i++)
24 var listener = new SimpleTraceListener(Console.Out);
20 q.Enqueue(data[i]);
25
21 }
26 var source = Trace<Program>.TraceSource;
27 source.Switch.Level = SourceLevels.All;
22
28
23 static bool TryDequeueRange<T>(ConcurrentQueue<T> q,T[] buffer,int offset, int len, out int actual) {
29 source.Listeners.Add(listener);
24 actual = 0;
30
25 T res;
31 var t = Environment.TickCount;
26 while(q.TryDequeue(out res)) {
27 buffer[offset + actual] = res;
28 actual++;
29 if (actual == len)
30 break;
31 }
32 return actual != 0;
33 }
34
32
35 static void EnqueueRange<T>(SimpleAsyncQueue<T> q, T[] data, int offset, int len) {
33 Main().Wait();
36 for (var i = offset; i < offset + len; i++)
34
37 q.Enqueue(data[i]);
35 Console.WriteLine($"Done: {Environment.TickCount - t} ms");
36 Console.ReadKey();
38 }
37 }
39
38
40 static bool TryDequeueRange<T>(SimpleAsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
39 static async Task Main() {
41 actual = 0;
40 using (LogicalOperation(nameof(Main))) {
42 T res;
41 Log("Start");
43 while (q.TryDequeue(out res)) {
42 await SomeAsync();
44 buffer[offset + actual] = res;
43 Log("End");
45 actual++;
46 if (actual == len)
47 break;
48 }
49 return actual != 0;
50 }
51
52 static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
53 for (var i = offset; i < offset + len; i++)
54 q.Enqueue(data[i]);
55 }
56
57 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
58 actual = 0;
59 T res;
60 while (q.TryDequeue(out res)) {
61 buffer[offset + actual] = res;
62 actual++;
63 if (actual == len)
64 break;
65 }
66 return actual != 0;
67 }
68
69
70 /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
71 q.EnqueueRange(data, offset, len);
72 }
73
74 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
75 return q.TryDequeueRange(buffer, offset, len, out actual);
76 }*/
77
78
79 static void Main(string[] args) {
80
81 var t = Environment.TickCount;
82 using (var reader = JsonReader.Create("e:\\citylots.json")) {
83 while (reader.Read()) {
84 }
44 }
85 }
45 }
86
46
87 Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms");
47 static async Task SomeAsync() {
88
48 using (LogicalOperation(nameof(SomeAsync))) {
89 Console.WriteLine("done");
49 Log("Do prepare");
50 await Task.Yield();
51 Log("Yield");
90 }
52 }
91 }
53 }
92 }
54 }
55 }
@@ -1,7 +1,8
1 <Project Sdk="Microsoft.NET.Sdk">
1 <Project Sdk="Microsoft.NET.Sdk">
2
2
3 <PropertyGroup>
3 <PropertyGroup>
4 <TargetFramework>netcoreapp2.0</TargetFramework>
4 <TargetFramework>net46</TargetFramework>
5 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
5
6
6 <IsPackable>false</IsPackable>
7 <IsPackable>false</IsPackable>
7 </PropertyGroup>
8 </PropertyGroup>
@@ -3,21 +3,21 using System.Collections.Generic;
3 using System.Diagnostics;
3 using System.Diagnostics;
4 using System.Linq;
4 using System.Linq;
5 using System.Text;
5 using System.Text;
6 using System.Threading;
6 using System.Threading.Tasks;
7 using System.Threading.Tasks;
7
8
8 namespace Implab.Diagnostics {
9 namespace Implab.Diagnostics {
9 public static class Trace<T> {
10 public static class Trace<T> {
10
11
11 readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name);
12 public static TraceSource TraceSource { get; } = new TraceSource(typeof(T).Name);
12
13
13 public static TraceSource TraceSource {
14 #if NETFX_TRACE_BUG
14 get { return _traceSource; }
15 readonly static AsyncLocal<object> m_currentOperation = new AsyncLocal<object>();
15 }
16 #endif
16
17
17 /// <summary>
18 /// <summary>
18 /// Starts the logical operation nested to the current operation nested to the current one.
19 /// Starts the logical operation nested to the current operation nested to the current one.
19 /// </summary>
20 /// </summary>
20 [Conditional("TRACE")]
21 public static void StartLogicalOperation() {
21 public static void StartLogicalOperation() {
22 Trace.CorrelationManager.StartLogicalOperation();
22 Trace.CorrelationManager.StartLogicalOperation();
23
23
@@ -27,15 +27,20 namespace Implab.Diagnostics {
27 /// Starts the logical operation with the specified name, this name is usefull in logs.
27 /// Starts the logical operation with the specified name, this name is usefull in logs.
28 /// </summary>
28 /// </summary>
29 /// <param name="name">Name.</param>
29 /// <param name="name">Name.</param>
30 [Conditional("TRACE")]
30 #if NETFX_TRACE_BUG
31 public static void StartLogicalOperation(string name) {
31 public static void StartLogicalOperation(object name) {
32 m_currentOperation.Value = name;
32 Trace.CorrelationManager.StartLogicalOperation(name);
33 Trace.CorrelationManager.StartLogicalOperation(name);
33 }
34 }
35 #else
36 public static void StartLogicalOperation(object name) {
37 Trace.CorrelationManager.StartLogicalOperation(name);
38 }
39 #endif
34
40
35 /// <summary>
41 /// <summary>
36 /// Ends the logical operation and restores the previous one.
42 /// Ends the logical operation and restores the previous one.
37 /// </summary>
43 /// </summary>
38 [Conditional("TRACE")]
39 public static void StopLogicalOperation() {
44 public static void StopLogicalOperation() {
40 Trace.CorrelationManager.StopLogicalOperation();
45 Trace.CorrelationManager.StopLogicalOperation();
41 }
46 }
@@ -120,7 +125,7 namespace Implab.Diagnostics {
120 public static LogicalOperationScope LogicalOperation(string name) {
125 public static LogicalOperationScope LogicalOperation(string name) {
121 var operation = new LogicalOperation(name);
126 var operation = new LogicalOperation(name);
122 TraceSource.TraceData(TraceEventType.Information, TraceEventCodes.StartLogicalOperation, operation);
127 TraceSource.TraceData(TraceEventType.Information, TraceEventCodes.StartLogicalOperation, operation);
123 Trace.CorrelationManager.StartLogicalOperation(operation);
128 StartLogicalOperation(operation);
124 return new LogicalOperationScope(TraceSource, operation);
129 return new LogicalOperationScope(TraceSource, operation);
125 }
130 }
126 }
131 }
@@ -11,8 +11,9
11 <LicenseUrl>https://opensource.org/licenses/BSD-2-Clause</LicenseUrl>
11 <LicenseUrl>https://opensource.org/licenses/BSD-2-Clause</LicenseUrl>
12 <ProjectUrl>https://implab.org</ProjectUrl>
12 <ProjectUrl>https://implab.org</ProjectUrl>
13 <RepositoryUrl>https://hg.implab.org/pub/ImplabNet/</RepositoryUrl>
13 <RepositoryUrl>https://hg.implab.org/pub/ImplabNet/</RepositoryUrl>
14 <TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
14 <TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net45' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
15 <FrameworkPathOverride Condition="'$(TargetFramework)'=='net46' and '$(OSTYPE)'=='linux'">/usr/lib/mono/4.5/</FrameworkPathOverride>
16 <DefineConstants Condition="'$(TargetFramework)'=='net46'">NETFX_TRACE_BUG;$(DefineConstants)</DefineConstants>
16 </PropertyGroup>
17 </PropertyGroup>
17
18
18 </Project>
19 </Project>
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