##// END OF EJS Templates
Added support for 'await' operator to promises
cin -
r151:ec91a6dfa5b3 v2
parent child
Show More
@@ -0,0 +1,28
1 using System;
2 using System.Runtime.CompilerServices;
3
4 namespace Implab {
5 public struct PromiseAwaiter : INotifyCompletion {
6 readonly IPromise m_promise;
7
8 public PromiseAwaiter(IPromise promise) {
9 m_promise = promise;
10 }
11
12 public void OnCompleted (Action continuation) {
13 if (m_promise != null)
14 m_promise.On(continuation, PromiseEventType.All);
15 }
16
17 public void GetResult() {
18 m_promise.Join();
19 }
20
21 public bool IsCompleted {
22 get {
23 return m_promise.IsResolved;
24 }
25 }
26 }
27 }
28
@@ -0,0 +1,28
1 using System;
2 using System.Runtime.CompilerServices;
3
4 namespace Implab {
5 public struct PromiseAwaiter<T> : INotifyCompletion {
6 readonly IPromise<T> m_promise;
7
8 public PromiseAwaiter(IPromise<T> promise) {
9 m_promise = promise;
10 }
11
12 public void OnCompleted (Action continuation) {
13 if (m_promise != null)
14 m_promise.On(continuation, PromiseEventType.All);
15 }
16
17 public T GetResult() {
18 return m_promise.Join();
19 }
20
21 public bool IsCompleted {
22 get {
23 return m_promise.IsResolved;
24 }
25 }
26 }
27 }
28
@@ -1,82 +1,83
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
1 ο»Ώ<?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <Project ToolsVersion="4.0" DefaultTargets="Build" 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 <ProductVersion>8.0.30703</ProductVersion>
6 <ProductVersion>8.0.30703</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</ProjectGuid>
8 <ProjectGuid>{06E706F8-6881-43EB-927E-FFC503AF6ABC}</ProjectGuid>
9 <OutputType>Library</OutputType>
9 <OutputType>Library</OutputType>
10 <AppDesignerFolder>Properties</AppDesignerFolder>
10 <AppDesignerFolder>Properties</AppDesignerFolder>
11 <RootNamespace>Implab.Fx</RootNamespace>
11 <RootNamespace>Implab.Fx</RootNamespace>
12 <AssemblyName>Implab.Fx</AssemblyName>
12 <AssemblyName>Implab.Fx</AssemblyName>
13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14 <FileAlignment>512</FileAlignment>
14 <FileAlignment>512</FileAlignment>
15 <ReleaseVersion>0.2</ReleaseVersion>
15 </PropertyGroup>
16 </PropertyGroup>
16 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17 <DebugSymbols>true</DebugSymbols>
18 <DebugSymbols>true</DebugSymbols>
18 <DebugType>full</DebugType>
19 <DebugType>full</DebugType>
19 <Optimize>false</Optimize>
20 <Optimize>false</Optimize>
20 <OutputPath>bin\Debug\</OutputPath>
21 <OutputPath>bin\Debug\</OutputPath>
21 <DefineConstants>DEBUG;TRACE</DefineConstants>
22 <DefineConstants>DEBUG;TRACE</DefineConstants>
22 <ErrorReport>prompt</ErrorReport>
23 <ErrorReport>prompt</ErrorReport>
23 <WarningLevel>4</WarningLevel>
24 <WarningLevel>4</WarningLevel>
24 </PropertyGroup>
25 </PropertyGroup>
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <DebugType>pdbonly</DebugType>
27 <DebugType>pdbonly</DebugType>
27 <Optimize>true</Optimize>
28 <Optimize>true</Optimize>
28 <OutputPath>bin\Release\</OutputPath>
29 <OutputPath>bin\Release\</OutputPath>
29 <DefineConstants>TRACE</DefineConstants>
30 <DefineConstants>TRACE</DefineConstants>
30 <ErrorReport>prompt</ErrorReport>
31 <ErrorReport>prompt</ErrorReport>
31 <WarningLevel>4</WarningLevel>
32 <WarningLevel>4</WarningLevel>
32 </PropertyGroup>
33 </PropertyGroup>
33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
34 <DebugSymbols>true</DebugSymbols>
35 <DebugSymbols>true</DebugSymbols>
35 <DebugType>full</DebugType>
36 <DebugType>full</DebugType>
36 <Optimize>false</Optimize>
37 <Optimize>false</Optimize>
37 <OutputPath>bin\Debug\</OutputPath>
38 <OutputPath>bin\Debug\</OutputPath>
38 <DefineConstants>DEBUG;TRACE</DefineConstants>
39 <DefineConstants>DEBUG;TRACE</DefineConstants>
39 <ErrorReport>prompt</ErrorReport>
40 <ErrorReport>prompt</ErrorReport>
40 <WarningLevel>4</WarningLevel>
41 <WarningLevel>4</WarningLevel>
41 </PropertyGroup>
42 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <DebugType>pdbonly</DebugType>
44 <DebugType>pdbonly</DebugType>
44 <Optimize>true</Optimize>
45 <Optimize>true</Optimize>
45 <OutputPath>bin\Release\</OutputPath>
46 <OutputPath>bin\Release\</OutputPath>
46 <DefineConstants>TRACE</DefineConstants>
47 <DefineConstants>TRACE</DefineConstants>
47 <ErrorReport>prompt</ErrorReport>
48 <ErrorReport>prompt</ErrorReport>
48 <WarningLevel>4</WarningLevel>
49 <WarningLevel>4</WarningLevel>
49 </PropertyGroup>
50 </PropertyGroup>
50 <ItemGroup>
51 <ItemGroup>
51 <Reference Include="System" />
52 <Reference Include="System" />
52 <Reference Include="System.Core" />
53 <Reference Include="System.Core" />
53 <Reference Include="System.Drawing" />
54 <Reference Include="System.Drawing" />
54 <Reference Include="System.Windows.Forms" />
55 <Reference Include="System.Windows.Forms" />
55 <Reference Include="System.Xml.Linq" />
56 <Reference Include="System.Xml.Linq" />
56 <Reference Include="System.Data.DataSetExtensions" />
57 <Reference Include="System.Data.DataSetExtensions" />
57 <Reference Include="Microsoft.CSharp" />
58 <Reference Include="Microsoft.CSharp" />
58 <Reference Include="System.Data" />
59 <Reference Include="System.Data" />
59 <Reference Include="System.Xml" />
60 <Reference Include="System.Xml" />
60 </ItemGroup>
61 </ItemGroup>
61 <ItemGroup>
62 <ItemGroup>
62 <Compile Include="Animation.cs" />
63 <Compile Include="Animation.cs" />
63 <Compile Include="AnimationHelpers.cs" />
64 <Compile Include="AnimationHelpers.cs" />
64 <Compile Include="PromiseHelpers.cs" />
65 <Compile Include="PromiseHelpers.cs" />
65 <Compile Include="Properties\AssemblyInfo.cs" />
66 <Compile Include="Properties\AssemblyInfo.cs" />
66 <Compile Include="ControlBoundPromise.cs" />
67 <Compile Include="ControlBoundPromise.cs" />
67 </ItemGroup>
68 </ItemGroup>
68 <ItemGroup>
69 <ItemGroup>
69 <ProjectReference Include="..\Implab\Implab.csproj">
70 <ProjectReference Include="..\Implab\Implab.csproj">
70 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
71 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
71 <Name>Implab</Name>
72 <Name>Implab</Name>
72 </ProjectReference>
73 </ProjectReference>
73 </ItemGroup>
74 </ItemGroup>
74 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
75 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
75 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
76 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
76 Other similar extension points exist, see Microsoft.Common.targets.
77 Other similar extension points exist, see Microsoft.Common.targets.
77 <Target Name="BeforeBuild">
78 <Target Name="BeforeBuild">
78 </Target>
79 </Target>
79 <Target Name="AfterBuild">
80 <Target Name="AfterBuild">
80 </Target>
81 </Target>
81 -->
82 -->
82 </Project> No newline at end of file
83 </Project>
@@ -1,850 +1,863
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
5
6 #if MONO
6 #if MONO
7
7
8 using NUnit.Framework;
8 using NUnit.Framework;
9 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
9 using TestClassAttribute = NUnit.Framework.TestFixtureAttribute;
10 using TestMethodAttribute = NUnit.Framework.TestAttribute;
10 using TestMethodAttribute = NUnit.Framework.TestAttribute;
11
11
12 #else
12 #else
13
13
14 using Microsoft.VisualStudio.TestTools.UnitTesting;
14 using Microsoft.VisualStudio.TestTools.UnitTesting;
15
15
16 #endif
16 #endif
17
17
18 namespace Implab.Test {
18 namespace Implab.Test {
19 [TestClass]
19 [TestClass]
20 public class AsyncTests {
20 public class AsyncTests {
21 [TestMethod]
21 [TestMethod]
22 public void ResolveTest() {
22 public void ResolveTest() {
23 int res = -1;
23 int res = -1;
24 var p = new Promise<int>();
24 var p = new Promise<int>();
25 p.Then(x => res = x);
25 p.Then(x => res = x);
26 p.Resolve(100);
26 p.Resolve(100);
27
27
28 Assert.AreEqual(100, res);
28 Assert.AreEqual(100, res);
29 }
29 }
30
30
31 [TestMethod]
31 [TestMethod]
32 public void RejectTest() {
32 public void RejectTest() {
33 int res = -1;
33 int res = -1;
34 Exception err = null;
34 Exception err = null;
35
35
36 var p = new Promise<int>();
36 var p = new Promise<int>();
37 p.Then(
37 p.Then(
38 x => res = x,
38 x => res = x,
39 e => {
39 e => {
40 err = e;
40 err = e;
41 return -2;
41 return -2;
42 }
42 }
43 );
43 );
44 p.Reject(new ApplicationException("error"));
44 p.Reject(new ApplicationException("error"));
45
45
46 Assert.AreEqual(res, -1);
46 Assert.AreEqual(res, -1);
47 Assert.AreEqual(err.Message, "error");
47 Assert.AreEqual(err.Message, "error");
48
48
49 }
49 }
50
50
51 [TestMethod]
51 [TestMethod]
52 public void CancelExceptionTest() {
52 public void CancelExceptionTest() {
53 var p = new Promise<bool>();
53 var p = new Promise<bool>();
54 p.CancelOperation(null);
54 p.CancelOperation(null);
55
55
56 var p2 = p.Then(x => x, null, reason => {
56 var p2 = p.Then(x => x, null, reason => {
57 throw new ApplicationException("CANCELLED");
57 throw new ApplicationException("CANCELLED");
58 });
58 });
59
59
60 try {
60 try {
61 p2.Join();
61 p2.Join();
62 Assert.Fail();
62 Assert.Fail();
63 } catch (ApplicationException err) {
63 } catch (ApplicationException err) {
64 Assert.AreEqual("CANCELLED", err.InnerException.Message);
64 Assert.AreEqual("CANCELLED", err.InnerException.Message);
65 }
65 }
66
66
67 }
67 }
68
68
69 [TestMethod]
69 [TestMethod]
70 public void ContinueOnCancelTest() {
70 public void ContinueOnCancelTest() {
71 var p = new Promise<bool>();
71 var p = new Promise<bool>();
72 p.CancelOperation(null);
72 p.CancelOperation(null);
73
73
74 var p2 = p
74 var p2 = p
75 .Then(x => x, null, reason => {
75 .Then(x => x, null, reason => {
76 throw new ApplicationException("CANCELLED");
76 throw new ApplicationException("CANCELLED");
77 })
77 })
78 .Then(x => x, e => true);
78 .Then(x => x, e => true);
79
79
80 Assert.AreEqual(true, p2.Join());
80 Assert.AreEqual(true, p2.Join());
81 }
81 }
82
82
83 [TestMethod]
83 [TestMethod]
84 public void JoinSuccessTest() {
84 public void JoinSuccessTest() {
85 var p = new Promise<int>();
85 var p = new Promise<int>();
86 p.Resolve(100);
86 p.Resolve(100);
87 Assert.AreEqual(p.Join(), 100);
87 Assert.AreEqual(p.Join(), 100);
88 }
88 }
89
89
90 [TestMethod]
90 [TestMethod]
91 public void JoinFailTest() {
91 public void JoinFailTest() {
92 var p = new Promise<int>();
92 var p = new Promise<int>();
93 p.Reject(new ApplicationException("failed"));
93 p.Reject(new ApplicationException("failed"));
94
94
95 try {
95 try {
96 p.Join();
96 p.Join();
97 throw new ApplicationException("WRONG!");
97 throw new ApplicationException("WRONG!");
98 } catch (TargetInvocationException err) {
98 } catch (TargetInvocationException err) {
99 Assert.AreEqual(err.InnerException.Message, "failed");
99 Assert.AreEqual(err.InnerException.Message, "failed");
100 } catch {
100 } catch {
101 Assert.Fail("Got wrong excaption");
101 Assert.Fail("Got wrong excaption");
102 }
102 }
103 }
103 }
104
104
105 [TestMethod]
105 [TestMethod]
106 public void MapTest() {
106 public void MapTest() {
107 var p = new Promise<int>();
107 var p = new Promise<int>();
108
108
109 var p2 = p.Then(x => x.ToString());
109 var p2 = p.Then(x => x.ToString());
110 p.Resolve(100);
110 p.Resolve(100);
111
111
112 Assert.AreEqual(p2.Join(), "100");
112 Assert.AreEqual(p2.Join(), "100");
113 }
113 }
114
114
115 [TestMethod]
115 [TestMethod]
116 public void FixErrorTest() {
116 public void FixErrorTest() {
117 var p = new Promise<int>();
117 var p = new Promise<int>();
118
118
119 var p2 = p.Then(x => x, e => 101);
119 var p2 = p.Then(x => x, e => 101);
120
120
121 p.Reject(new Exception());
121 p.Reject(new Exception());
122
122
123 Assert.AreEqual(p2.Join(), 101);
123 Assert.AreEqual(p2.Join(), 101);
124 }
124 }
125
125
126 [TestMethod]
126 [TestMethod]
127 public void ChainTest() {
127 public void ChainTest() {
128 var p1 = new Promise<int>();
128 var p1 = new Promise<int>();
129
129
130 var p3 = p1.Chain(x => {
130 var p3 = p1.Chain(x => {
131 var p2 = new Promise<string>();
131 var p2 = new Promise<string>();
132 p2.Resolve(x.ToString());
132 p2.Resolve(x.ToString());
133 return p2;
133 return p2;
134 });
134 });
135
135
136 p1.Resolve(100);
136 p1.Resolve(100);
137
137
138 Assert.AreEqual(p3.Join(), "100");
138 Assert.AreEqual(p3.Join(), "100");
139 }
139 }
140
140
141 [TestMethod]
141 [TestMethod]
142 public void ChainFailTest() {
142 public void ChainFailTest() {
143 var p1 = new Promise<int>();
143 var p1 = new Promise<int>();
144
144
145 var p3 = p1.Chain(x => {
145 var p3 = p1.Chain(x => {
146 var p2 = new Promise<string>();
146 var p2 = new Promise<string>();
147 p2.Reject(new Exception("DIE!!!"));
147 p2.Reject(new Exception("DIE!!!"));
148 return p2;
148 return p2;
149 });
149 });
150
150
151 p1.Resolve(100);
151 p1.Resolve(100);
152
152
153 Assert.IsTrue(p3.IsResolved);
153 Assert.IsTrue(p3.IsResolved);
154 }
154 }
155
155
156 [TestMethod]
156 [TestMethod]
157 public void PoolTest() {
157 public void PoolTest() {
158 var pid = Thread.CurrentThread.ManagedThreadId;
158 var pid = Thread.CurrentThread.ManagedThreadId;
159 var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId);
159 var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId);
160
160
161 Assert.AreNotEqual(pid, p.Join());
161 Assert.AreNotEqual(pid, p.Join());
162 }
162 }
163
163
164 [TestMethod]
164 [TestMethod]
165 public void WorkerPoolSizeTest() {
165 public void WorkerPoolSizeTest() {
166 var pool = new WorkerPool(5, 10, 1);
166 var pool = new WorkerPool(5, 10, 1);
167
167
168 Assert.AreEqual(5, pool.PoolSize);
168 Assert.AreEqual(5, pool.PoolSize);
169
169
170 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
170 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
171 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
171 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
172 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
172 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
173
173
174 Assert.AreEqual(5, pool.PoolSize);
174 Assert.AreEqual(5, pool.PoolSize);
175
175
176 for (int i = 0; i < 100; i++)
176 for (int i = 0; i < 100; i++)
177 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
177 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
178 Thread.Sleep(200);
178 Thread.Sleep(200);
179 Assert.AreEqual(10, pool.PoolSize);
179 Assert.AreEqual(10, pool.PoolSize);
180
180
181 pool.Dispose();
181 pool.Dispose();
182 }
182 }
183
183
184 [TestMethod]
184 [TestMethod]
185 public void WorkerPoolCorrectTest() {
185 public void WorkerPoolCorrectTest() {
186 var pool = new WorkerPool(0,1000,100);
186 var pool = new WorkerPool(0,1000,100);
187
187
188 const int iterations = 1000;
188 const int iterations = 1000;
189 int pending = iterations;
189 int pending = iterations;
190 var stop = new ManualResetEvent(false);
190 var stop = new ManualResetEvent(false);
191
191
192 var count = 0;
192 var count = 0;
193 for (int i = 0; i < iterations; i++) {
193 for (int i = 0; i < iterations; i++) {
194 pool
194 pool
195 .Invoke(() => 1)
195 .Invoke(() => 1)
196 .Then(x => Interlocked.Add(ref count, x))
196 .Then(x => Interlocked.Add(ref count, x))
197 .Then(x => Math.Log10(x))
197 .Then(x => Math.Log10(x))
198 .On(() => {
198 .On(() => {
199 Interlocked.Decrement(ref pending);
199 Interlocked.Decrement(ref pending);
200 if (pending == 0)
200 if (pending == 0)
201 stop.Set();
201 stop.Set();
202 }, PromiseEventType.All);
202 }, PromiseEventType.All);
203 }
203 }
204
204
205 stop.WaitOne();
205 stop.WaitOne();
206
206
207 Assert.AreEqual(iterations, count);
207 Assert.AreEqual(iterations, count);
208 Console.WriteLine("Max threads: {0}", pool.MaxRunningThreads);
208 Console.WriteLine("Max threads: {0}", pool.MaxRunningThreads);
209 pool.Dispose();
209 pool.Dispose();
210
210
211 }
211 }
212
212
213 [TestMethod]
213 [TestMethod]
214 public void WorkerPoolDisposeTest() {
214 public void WorkerPoolDisposeTest() {
215 var pool = new WorkerPool(5, 20);
215 var pool = new WorkerPool(5, 20);
216 Assert.AreEqual(5, pool.PoolSize);
216 Assert.AreEqual(5, pool.PoolSize);
217 pool.Dispose();
217 pool.Dispose();
218 Thread.Sleep(500);
218 Thread.Sleep(500);
219 Assert.AreEqual(0, pool.PoolSize);
219 Assert.AreEqual(0, pool.PoolSize);
220 pool.Dispose();
220 pool.Dispose();
221 }
221 }
222
222
223 [TestMethod]
223 [TestMethod]
224 public void MTQueueTest() {
224 public void MTQueueTest() {
225 var queue = new MTQueue<int>();
225 var queue = new MTQueue<int>();
226 int res;
226 int res;
227
227
228 queue.Enqueue(10);
228 queue.Enqueue(10);
229 Assert.IsTrue(queue.TryDequeue(out res));
229 Assert.IsTrue(queue.TryDequeue(out res));
230 Assert.AreEqual(10, res);
230 Assert.AreEqual(10, res);
231 Assert.IsFalse(queue.TryDequeue(out res));
231 Assert.IsFalse(queue.TryDequeue(out res));
232
232
233 for (int i = 0; i < 1000; i++)
233 for (int i = 0; i < 1000; i++)
234 queue.Enqueue(i);
234 queue.Enqueue(i);
235
235
236 for (int i = 0; i < 1000; i++) {
236 for (int i = 0; i < 1000; i++) {
237 queue.TryDequeue(out res);
237 queue.TryDequeue(out res);
238 Assert.AreEqual(i, res);
238 Assert.AreEqual(i, res);
239 }
239 }
240
240
241 int writers = 0;
241 int writers = 0;
242 int readers = 0;
242 int readers = 0;
243 var stop = new ManualResetEvent(false);
243 var stop = new ManualResetEvent(false);
244 int total = 0;
244 int total = 0;
245
245
246 const int itemsPerWriter = 10000;
246 const int itemsPerWriter = 10000;
247 const int writersCount = 10;
247 const int writersCount = 10;
248
248
249 for (int i = 0; i < writersCount; i++) {
249 for (int i = 0; i < writersCount; i++) {
250 Interlocked.Increment(ref writers);
250 Interlocked.Increment(ref writers);
251 AsyncPool
251 AsyncPool
252 .RunThread(() => {
252 .RunThread(() => {
253 for (int ii = 0; ii < itemsPerWriter; ii++) {
253 for (int ii = 0; ii < itemsPerWriter; ii++) {
254 queue.Enqueue(1);
254 queue.Enqueue(1);
255 }
255 }
256 return 1;
256 return 1;
257 })
257 })
258 .On(() => Interlocked.Decrement(ref writers), PromiseEventType.All);
258 .On(() => Interlocked.Decrement(ref writers), PromiseEventType.All);
259 }
259 }
260
260
261 for (int i = 0; i < 10; i++) {
261 for (int i = 0; i < 10; i++) {
262 Interlocked.Increment(ref readers);
262 Interlocked.Increment(ref readers);
263 AsyncPool
263 AsyncPool
264 .RunThread(() => {
264 .RunThread(() => {
265 int t;
265 int t;
266 do {
266 do {
267 while (queue.TryDequeue(out t))
267 while (queue.TryDequeue(out t))
268 Interlocked.Add(ref total, t);
268 Interlocked.Add(ref total, t);
269 } while (writers > 0);
269 } while (writers > 0);
270 return 1;
270 return 1;
271 })
271 })
272 .On(() => {
272 .On(() => {
273 Interlocked.Decrement(ref readers);
273 Interlocked.Decrement(ref readers);
274 if (readers == 0)
274 if (readers == 0)
275 stop.Set();
275 stop.Set();
276 }, PromiseEventType.All);
276 }, PromiseEventType.All);
277 }
277 }
278
278
279 stop.WaitOne();
279 stop.WaitOne();
280
280
281 Assert.AreEqual(100000, total);
281 Assert.AreEqual(100000, total);
282 }
282 }
283
283
284 [TestMethod]
284 [TestMethod]
285 public void AsyncQueueTest() {
285 public void AsyncQueueTest() {
286 var queue = new AsyncQueue<int>();
286 var queue = new AsyncQueue<int>();
287 int res;
287 int res;
288
288
289 queue.Enqueue(10);
289 queue.Enqueue(10);
290 Assert.IsTrue(queue.TryDequeue(out res));
290 Assert.IsTrue(queue.TryDequeue(out res));
291 Assert.AreEqual(10, res);
291 Assert.AreEqual(10, res);
292 Assert.IsFalse(queue.TryDequeue(out res));
292 Assert.IsFalse(queue.TryDequeue(out res));
293
293
294 for (int i = 0; i < 1000; i++)
294 for (int i = 0; i < 1000; i++)
295 queue.Enqueue(i);
295 queue.Enqueue(i);
296
296
297 for (int i = 0; i < 1000; i++) {
297 for (int i = 0; i < 1000; i++) {
298 queue.TryDequeue(out res);
298 queue.TryDequeue(out res);
299 Assert.AreEqual(i, res);
299 Assert.AreEqual(i, res);
300 }
300 }
301
301
302 const int count = 10000000;
302 const int count = 10000000;
303
303
304 int res1 = 0, res2 = 0;
304 int res1 = 0, res2 = 0;
305 var t1 = Environment.TickCount;
305 var t1 = Environment.TickCount;
306
306
307 AsyncPool.RunThread(
307 AsyncPool.RunThread(
308 () => {
308 () => {
309 for (var i = 0; i < count; i++)
309 for (var i = 0; i < count; i++)
310 queue.Enqueue(1);
310 queue.Enqueue(1);
311 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
311 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
312 },
312 },
313 () => {
313 () => {
314 for (var i = 0; i < count; i++)
314 for (var i = 0; i < count; i++)
315 queue.Enqueue(2);
315 queue.Enqueue(2);
316 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
316 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
317 },
317 },
318 () => {
318 () => {
319 int temp;
319 int temp;
320 int i = 0;
320 int i = 0;
321 while (i < count)
321 while (i < count)
322 if (queue.TryDequeue(out temp)) {
322 if (queue.TryDequeue(out temp)) {
323 i++;
323 i++;
324 res1 += temp;
324 res1 += temp;
325 }
325 }
326 Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
326 Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
327 },
327 },
328 () => {
328 () => {
329 int temp;
329 int temp;
330 int i = 0;
330 int i = 0;
331 while (i < count)
331 while (i < count)
332 if (queue.TryDequeue(out temp)) {
332 if (queue.TryDequeue(out temp)) {
333 i++;
333 i++;
334 res2 += temp;
334 res2 += temp;
335 }
335 }
336 Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
336 Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
337 }
337 }
338 )
338 )
339 .Bundle()
339 .Bundle()
340 .Join();
340 .Join();
341
341
342 Assert.AreEqual(count * 3, res1 + res2);
342 Assert.AreEqual(count * 3, res1 + res2);
343
343
344 Console.WriteLine(
344 Console.WriteLine(
345 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
345 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
346 Environment.TickCount - t1,
346 Environment.TickCount - t1,
347 res1,
347 res1,
348 res2,
348 res2,
349 res1 + res2,
349 res1 + res2,
350 count
350 count
351 );
351 );
352 }
352 }
353
353
354 [TestMethod]
354 [TestMethod]
355 public void AsyncQueueBatchTest() {
355 public void AsyncQueueBatchTest() {
356 var queue = new AsyncQueue<int>();
356 var queue = new AsyncQueue<int>();
357
357
358 const int wBatch = 29;
358 const int wBatch = 29;
359 const int wCount = 400000;
359 const int wCount = 400000;
360 const int total = wBatch * wCount * 2;
360 const int total = wBatch * wCount * 2;
361 const int summ = wBatch * wCount * 3;
361 const int summ = wBatch * wCount * 3;
362
362
363 int r1 = 0, r2 = 0;
363 int r1 = 0, r2 = 0;
364 const int rBatch = 111;
364 const int rBatch = 111;
365 int read = 0;
365 int read = 0;
366
366
367 var t1 = Environment.TickCount;
367 var t1 = Environment.TickCount;
368
368
369 AsyncPool.RunThread(
369 AsyncPool.RunThread(
370 () => {
370 () => {
371 var buffer = new int[wBatch];
371 var buffer = new int[wBatch];
372 for(int i = 0; i<wBatch; i++)
372 for(int i = 0; i<wBatch; i++)
373 buffer[i] = 1;
373 buffer[i] = 1;
374
374
375 for(int i =0; i < wCount; i++)
375 for(int i =0; i < wCount; i++)
376 queue.EnqueueRange(buffer,0,wBatch);
376 queue.EnqueueRange(buffer,0,wBatch);
377 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
377 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
378 },
378 },
379 () => {
379 () => {
380 var buffer = new int[wBatch];
380 var buffer = new int[wBatch];
381 for(int i = 0; i<wBatch; i++)
381 for(int i = 0; i<wBatch; i++)
382 buffer[i] = 2;
382 buffer[i] = 2;
383
383
384 for(int i =0; i < wCount; i++)
384 for(int i =0; i < wCount; i++)
385 queue.EnqueueRange(buffer,0,wBatch);
385 queue.EnqueueRange(buffer,0,wBatch);
386 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
386 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
387 },
387 },
388 () => {
388 () => {
389 var buffer = new int[rBatch];
389 var buffer = new int[rBatch];
390
390
391 while(read < total) {
391 while(read < total) {
392 int actual;
392 int actual;
393 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
393 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
394 for(int i=0; i< actual; i++)
394 for(int i=0; i< actual; i++)
395 r1 += buffer[i];
395 r1 += buffer[i];
396 Interlocked.Add(ref read, actual);
396 Interlocked.Add(ref read, actual);
397 }
397 }
398 }
398 }
399
399
400 Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
400 Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
401 },
401 },
402 () => {
402 () => {
403 var buffer = new int[rBatch];
403 var buffer = new int[rBatch];
404
404
405 while(read < total) {
405 while(read < total) {
406 int actual;
406 int actual;
407 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
407 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
408 for(int i=0; i< actual; i++)
408 for(int i=0; i< actual; i++)
409 r2 += buffer[i];
409 r2 += buffer[i];
410 Interlocked.Add(ref read, actual);
410 Interlocked.Add(ref read, actual);
411 }
411 }
412 }
412 }
413
413
414 Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
414 Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
415 }
415 }
416 )
416 )
417 .Bundle()
417 .Bundle()
418 .Join();
418 .Join();
419
419
420 Assert.AreEqual(summ , r1 + r2);
420 Assert.AreEqual(summ , r1 + r2);
421
421
422 Console.WriteLine(
422 Console.WriteLine(
423 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
423 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
424 Environment.TickCount - t1,
424 Environment.TickCount - t1,
425 r1,
425 r1,
426 r2,
426 r2,
427 r1 + r2,
427 r1 + r2,
428 total
428 total
429 );
429 );
430 }
430 }
431
431
432 [TestMethod]
432 [TestMethod]
433 public void AsyncQueueChunkDequeueTest() {
433 public void AsyncQueueChunkDequeueTest() {
434 var queue = new AsyncQueue<int>();
434 var queue = new AsyncQueue<int>();
435
435
436 const int wBatch = 31;
436 const int wBatch = 31;
437 const int wCount = 200000;
437 const int wCount = 200000;
438 const int total = wBatch * wCount * 3;
438 const int total = wBatch * wCount * 3;
439 const int summ = wBatch * wCount * 6;
439 const int summ = wBatch * wCount * 6;
440
440
441 int r1 = 0, r2 = 0;
441 int r1 = 0, r2 = 0;
442 const int rBatch = 1024;
442 const int rBatch = 1024;
443 int read = 0;
443 int read = 0;
444
444
445 var t1 = Environment.TickCount;
445 var t1 = Environment.TickCount;
446
446
447 AsyncPool.RunThread(
447 AsyncPool.RunThread(
448 () => {
448 () => {
449 var buffer = new int[wBatch];
449 var buffer = new int[wBatch];
450 for(int i = 0; i<wBatch; i++)
450 for(int i = 0; i<wBatch; i++)
451 buffer[i] = 1;
451 buffer[i] = 1;
452
452
453 for(int i =0; i < wCount; i++)
453 for(int i =0; i < wCount; i++)
454 queue.EnqueueRange(buffer,0,wBatch);
454 queue.EnqueueRange(buffer,0,wBatch);
455 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
455 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
456 },
456 },
457 () => {
457 () => {
458 var buffer = new int[wBatch];
458 var buffer = new int[wBatch];
459 for(int i = 0; i<wBatch; i++)
459 for(int i = 0; i<wBatch; i++)
460 buffer[i] = 2;
460 buffer[i] = 2;
461
461
462 for(int i =0; i < wCount; i++)
462 for(int i =0; i < wCount; i++)
463 queue.EnqueueRange(buffer,0,wBatch);
463 queue.EnqueueRange(buffer,0,wBatch);
464 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
464 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
465 },
465 },
466 () => {
466 () => {
467 var buffer = new int[wBatch];
467 var buffer = new int[wBatch];
468 for(int i = 0; i<wBatch; i++)
468 for(int i = 0; i<wBatch; i++)
469 buffer[i] = 3;
469 buffer[i] = 3;
470
470
471 for(int i =0; i < wCount; i++)
471 for(int i =0; i < wCount; i++)
472 queue.EnqueueRange(buffer,0,wBatch);
472 queue.EnqueueRange(buffer,0,wBatch);
473 Console.WriteLine("done writer #3: {0} ms", Environment.TickCount - t1);
473 Console.WriteLine("done writer #3: {0} ms", Environment.TickCount - t1);
474 },
474 },
475 () => {
475 () => {
476 var buffer = new int[rBatch];
476 var buffer = new int[rBatch];
477 int count = 1;
477 int count = 1;
478 double avgchunk = 0;
478 double avgchunk = 0;
479 while(read < total) {
479 while(read < total) {
480 int actual;
480 int actual;
481 if (queue.TryDequeueChunk(buffer,0,rBatch,out actual)) {
481 if (queue.TryDequeueChunk(buffer,0,rBatch,out actual)) {
482 for(int i=0; i< actual; i++)
482 for(int i=0; i< actual; i++)
483 r2 += buffer[i];
483 r2 += buffer[i];
484 Interlocked.Add(ref read, actual);
484 Interlocked.Add(ref read, actual);
485 avgchunk = avgchunk*(count-1)/count + actual/(double)count;
485 avgchunk = avgchunk*(count-1)/count + actual/(double)count;
486 count ++;
486 count ++;
487 }
487 }
488 }
488 }
489
489
490 Console.WriteLine("done reader #2: {0} ms, avg chunk size: {1}", Environment.TickCount - t1, avgchunk);
490 Console.WriteLine("done reader #2: {0} ms, avg chunk size: {1}", Environment.TickCount - t1, avgchunk);
491 }
491 }
492 )
492 )
493 .Bundle()
493 .Bundle()
494 .Join();
494 .Join();
495
495
496 Assert.AreEqual(summ , r1 + r2);
496 Assert.AreEqual(summ , r1 + r2);
497
497
498 Console.WriteLine(
498 Console.WriteLine(
499 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
499 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
500 Environment.TickCount - t1,
500 Environment.TickCount - t1,
501 r1,
501 r1,
502 r2,
502 r2,
503 r1 + r2,
503 r1 + r2,
504 total
504 total
505 );
505 );
506 }
506 }
507
507
508 [TestMethod]
508 [TestMethod]
509 public void AsyncQueueDrainTest() {
509 public void AsyncQueueDrainTest() {
510 var queue = new AsyncQueue<int>();
510 var queue = new AsyncQueue<int>();
511
511
512 const int wBatch = 11;
512 const int wBatch = 11;
513 const int wCount = 200000;
513 const int wCount = 200000;
514 const int total = wBatch * wCount * 3;
514 const int total = wBatch * wCount * 3;
515 const int summ = wBatch * wCount * 3;
515 const int summ = wBatch * wCount * 3;
516
516
517 int r1 = 0, r2 = 0;
517 int r1 = 0, r2 = 0;
518 const int rBatch = 11;
518 const int rBatch = 11;
519 int read = 0;
519 int read = 0;
520
520
521 var t1 = Environment.TickCount;
521 var t1 = Environment.TickCount;
522
522
523 AsyncPool.RunThread(
523 AsyncPool.RunThread(
524 () => {
524 () => {
525 var buffer = new int[wBatch];
525 var buffer = new int[wBatch];
526 for(int i = 0; i<wBatch; i++)
526 for(int i = 0; i<wBatch; i++)
527 buffer[i] = 1;
527 buffer[i] = 1;
528
528
529 for(int i =0; i < wCount; i++)
529 for(int i =0; i < wCount; i++)
530 queue.EnqueueRange(buffer,0,wBatch);
530 queue.EnqueueRange(buffer,0,wBatch);
531 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
531 Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
532 },
532 },
533 () => {
533 () => {
534 for(int i =0; i < wCount * wBatch; i++)
534 for(int i =0; i < wCount * wBatch; i++)
535 queue.Enqueue(1);
535 queue.Enqueue(1);
536 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
536 Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
537 },
537 },
538 () => {
538 () => {
539 var buffer = new int[wBatch];
539 var buffer = new int[wBatch];
540 for(int i = 0; i<wBatch; i++)
540 for(int i = 0; i<wBatch; i++)
541 buffer[i] = 1;
541 buffer[i] = 1;
542
542
543 for(int i =0; i < wCount; i++)
543 for(int i =0; i < wCount; i++)
544 queue.EnqueueRange(buffer,0,wBatch);
544 queue.EnqueueRange(buffer,0,wBatch);
545 Console.WriteLine("done writer #3: {0} ms", Environment.TickCount - t1);
545 Console.WriteLine("done writer #3: {0} ms", Environment.TickCount - t1);
546 },
546 },
547 /*() => {
547 /*() => {
548 int temp;
548 int temp;
549 int count = 0;
549 int count = 0;
550 while (read < total)
550 while (read < total)
551 if (queue.TryDequeue(out temp)) {
551 if (queue.TryDequeue(out temp)) {
552 count++;
552 count++;
553 r1 += temp;
553 r1 += temp;
554 Interlocked.Increment(ref read);
554 Interlocked.Increment(ref read);
555 }
555 }
556 Console.WriteLine("done reader #1: {0} ms, {1} count", Environment.TickCount - t1, count);
556 Console.WriteLine("done reader #1: {0} ms, {1} count", Environment.TickCount - t1, count);
557 },*/
557 },*/
558 /*() => {
558 /*() => {
559 var buffer = new int[rBatch];
559 var buffer = new int[rBatch];
560 var count = 0;
560 var count = 0;
561 while(read < total) {
561 while(read < total) {
562 int actual;
562 int actual;
563 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
563 if (queue.TryDequeueRange(buffer,0,rBatch,out actual)) {
564 for(int i=0; i< actual; i++)
564 for(int i=0; i< actual; i++)
565 r1 += buffer[i];
565 r1 += buffer[i];
566 Interlocked.Add(ref read, actual);
566 Interlocked.Add(ref read, actual);
567 count += actual;
567 count += actual;
568 }
568 }
569 }
569 }
570
570
571 Console.WriteLine("done reader #1: {0} ms, {1} items", Environment.TickCount - t1, count);
571 Console.WriteLine("done reader #1: {0} ms, {1} items", Environment.TickCount - t1, count);
572 },*/
572 },*/
573 () => {
573 () => {
574 var count = 0;
574 var count = 0;
575 while(read < total) {
575 while(read < total) {
576 var buffer = queue.Drain();
576 var buffer = queue.Drain();
577 for(int i=0; i< buffer.Length; i++)
577 for(int i=0; i< buffer.Length; i++)
578 r1 += buffer[i];
578 r1 += buffer[i];
579 Interlocked.Add(ref read, buffer.Length);
579 Interlocked.Add(ref read, buffer.Length);
580 count += buffer.Length;
580 count += buffer.Length;
581 }
581 }
582 Console.WriteLine("done reader #1: {0} ms, {1} items", Environment.TickCount - t1, count);
582 Console.WriteLine("done reader #1: {0} ms, {1} items", Environment.TickCount - t1, count);
583 },
583 },
584 () => {
584 () => {
585 var count = 0;
585 var count = 0;
586 while(read < total) {
586 while(read < total) {
587 var buffer = queue.Drain();
587 var buffer = queue.Drain();
588 for(int i=0; i< buffer.Length; i++)
588 for(int i=0; i< buffer.Length; i++)
589 r2 += buffer[i];
589 r2 += buffer[i];
590 Interlocked.Add(ref read, buffer.Length);
590 Interlocked.Add(ref read, buffer.Length);
591 count += buffer.Length;
591 count += buffer.Length;
592 }
592 }
593 Console.WriteLine("done reader #2: {0} ms, {1} items", Environment.TickCount - t1, count);
593 Console.WriteLine("done reader #2: {0} ms, {1} items", Environment.TickCount - t1, count);
594 }
594 }
595 )
595 )
596 .Bundle()
596 .Bundle()
597 .Join();
597 .Join();
598
598
599 Assert.AreEqual(summ , r1 + r2);
599 Assert.AreEqual(summ , r1 + r2);
600
600
601 Console.WriteLine(
601 Console.WriteLine(
602 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
602 "done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}",
603 Environment.TickCount - t1,
603 Environment.TickCount - t1,
604 r1,
604 r1,
605 r2,
605 r2,
606 r1 + r2,
606 r1 + r2,
607 total
607 total
608 );
608 );
609 }
609 }
610
610
611 [TestMethod]
611 [TestMethod]
612 public void ParallelMapTest() {
612 public void ParallelMapTest() {
613
613
614 const int count = 100000;
614 const int count = 100000;
615
615
616 var args = new double[count];
616 var args = new double[count];
617 var rand = new Random();
617 var rand = new Random();
618
618
619 for (int i = 0; i < count; i++)
619 for (int i = 0; i < count; i++)
620 args[i] = rand.NextDouble();
620 args[i] = rand.NextDouble();
621
621
622 var t = Environment.TickCount;
622 var t = Environment.TickCount;
623 var res = args.ParallelMap(x => Math.Sin(x*x), 4).Join();
623 var res = args.ParallelMap(x => Math.Sin(x*x), 4).Join();
624
624
625 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
625 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
626
626
627 t = Environment.TickCount;
627 t = Environment.TickCount;
628 for (int i = 0; i < count; i++)
628 for (int i = 0; i < count; i++)
629 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
629 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
630 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
630 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
631 }
631 }
632
632
633 [TestMethod]
633 [TestMethod]
634 public void ChainedMapTest() {
634 public void ChainedMapTest() {
635
635
636 using (var pool = new WorkerPool()) {
636 using (var pool = new WorkerPool()) {
637 const int count = 10000;
637 const int count = 10000;
638
638
639 var args = new double[count];
639 var args = new double[count];
640 var rand = new Random();
640 var rand = new Random();
641
641
642 for (int i = 0; i < count; i++)
642 for (int i = 0; i < count; i++)
643 args[i] = rand.NextDouble();
643 args[i] = rand.NextDouble();
644
644
645 var t = Environment.TickCount;
645 var t = Environment.TickCount;
646 var res = args
646 var res = args
647 .ChainedMap(
647 .ChainedMap(
648 // Analysis disable once AccessToDisposedClosure
648 // Analysis disable once AccessToDisposedClosure
649 x => pool.Invoke(
649 x => pool.Invoke(
650 () => Math.Sin(x * x)
650 () => Math.Sin(x * x)
651 ),
651 ),
652 4
652 4
653 )
653 )
654 .Join();
654 .Join();
655
655
656 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
656 Console.WriteLine("Map complete in {0} ms", Environment.TickCount - t);
657
657
658 t = Environment.TickCount;
658 t = Environment.TickCount;
659 for (int i = 0; i < count; i++)
659 for (int i = 0; i < count; i++)
660 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
660 Assert.AreEqual(Math.Sin(args[i] * args[i]), res[i]);
661 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
661 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
662 Console.WriteLine("Max workers: {0}", pool.MaxRunningThreads);
662 Console.WriteLine("Max workers: {0}", pool.MaxRunningThreads);
663 }
663 }
664 }
664 }
665
665
666 [TestMethod]
666 [TestMethod]
667 public void ParallelForEachTest() {
667 public void ParallelForEachTest() {
668
668
669 const int count = 100000;
669 const int count = 100000;
670
670
671 var args = new int[count];
671 var args = new int[count];
672 var rand = new Random();
672 var rand = new Random();
673
673
674 for (int i = 0; i < count; i++)
674 for (int i = 0; i < count; i++)
675 args[i] = (int)(rand.NextDouble() * 100);
675 args[i] = (int)(rand.NextDouble() * 100);
676
676
677 int result = 0;
677 int result = 0;
678
678
679 var t = Environment.TickCount;
679 var t = Environment.TickCount;
680 args.ParallelForEach(x => Interlocked.Add(ref result, x), 4).Join();
680 args.ParallelForEach(x => Interlocked.Add(ref result, x), 4).Join();
681
681
682 Console.WriteLine("Iteration complete in {0} ms, result: {1}", Environment.TickCount - t, result);
682 Console.WriteLine("Iteration complete in {0} ms, result: {1}", Environment.TickCount - t, result);
683
683
684 int result2 = 0;
684 int result2 = 0;
685
685
686 t = Environment.TickCount;
686 t = Environment.TickCount;
687 for (int i = 0; i < count; i++)
687 for (int i = 0; i < count; i++)
688 result2 += args[i];
688 result2 += args[i];
689 Assert.AreEqual(result2, result);
689 Assert.AreEqual(result2, result);
690 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
690 Console.WriteLine("Verified in {0} ms", Environment.TickCount - t);
691 }
691 }
692
692
693 [TestMethod]
693 [TestMethod]
694 public void ComplexCase1Test() {
694 public void ComplexCase1Test() {
695 var flags = new bool[3];
695 var flags = new bool[3];
696
696
697 // op1 (aync 200ms) => op2 (async 200ms) => op3 (sync map)
697 // op1 (aync 200ms) => op2 (async 200ms) => op3 (sync map)
698
698
699 var step1 = PromiseHelper
699 var step1 = PromiseHelper
700 .Sleep(200, "Alan")
700 .Sleep(200, "Alan")
701 .On(() => flags[0] = true, PromiseEventType.Cancelled);
701 .On(() => flags[0] = true, PromiseEventType.Cancelled);
702 var p = step1
702 var p = step1
703 .Chain(x =>
703 .Chain(x =>
704 PromiseHelper
704 PromiseHelper
705 .Sleep(200, "Hi, " + x)
705 .Sleep(200, "Hi, " + x)
706 .Then(y => y)
706 .Then(y => y)
707 .On(() => flags[1] = true, PromiseEventType.Cancelled)
707 .On(() => flags[1] = true, PromiseEventType.Cancelled)
708 )
708 )
709 .On(() => flags[2] = true, PromiseEventType.Cancelled);
709 .On(() => flags[2] = true, PromiseEventType.Cancelled);
710 step1.Join();
710 step1.Join();
711 p.Cancel();
711 p.Cancel();
712 try {
712 try {
713 Assert.AreEqual(p.Join(), "Hi, Alan");
713 Assert.AreEqual(p.Join(), "Hi, Alan");
714 Assert.Fail("Shouldn't get here");
714 Assert.Fail("Shouldn't get here");
715 } catch (OperationCanceledException) {
715 } catch (OperationCanceledException) {
716 }
716 }
717
717
718 Assert.IsFalse(flags[0]);
718 Assert.IsFalse(flags[0]);
719 Assert.IsTrue(flags[1]);
719 Assert.IsTrue(flags[1]);
720 Assert.IsTrue(flags[2]);
720 Assert.IsTrue(flags[2]);
721 }
721 }
722
722
723 [TestMethod]
723 [TestMethod]
724 public void ChainedCancel1Test() {
724 public void ChainedCancel1Test() {
725 // ΠΏΡ€ΠΈ ΠΎΡ‚ΠΌΠ΅Π½Π΅ сцСплСнной асинхронной ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ всС ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ
725 // ΠΏΡ€ΠΈ ΠΎΡ‚ΠΌΠ΅Π½Π΅ сцСплСнной асинхронной ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ всС ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ
726 // Π·Π°Π²Π΅Ρ€ΡˆΠ°Ρ‚ΡŒΡΡ ошибкой OperationCanceledException
726 // Π·Π°Π²Π΅Ρ€ΡˆΠ°Ρ‚ΡŒΡΡ ошибкой OperationCanceledException
727 var p = PromiseHelper
727 var p = PromiseHelper
728 .Sleep(1, "Hi, HAL!")
728 .Sleep(1, "Hi, HAL!")
729 .Then(x => {
729 .Then(x => {
730 // запускаСм Π΄Π²Π΅ асинхронныС ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ
730 // запускаСм Π΄Π²Π΅ асинхронныС ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ
731 var result = PromiseHelper.Sleep(1000, "HEM ENABLED!!!");
731 var result = PromiseHelper.Sleep(1000, "HEM ENABLED!!!");
732 // вторая опСрация отмСняСт ΠΏΠ΅Ρ€Π²ΡƒΡŽ Π΄ΠΎ Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½ΠΈΡ
732 // вторая опСрация отмСняСт ΠΏΠ΅Ρ€Π²ΡƒΡŽ Π΄ΠΎ Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½ΠΈΡ
733 PromiseHelper
733 PromiseHelper
734 .Sleep(100, "HAL, STOP!")
734 .Sleep(100, "HAL, STOP!")
735 .Then(result.Cancel);
735 .Then(result.Cancel);
736 return result;
736 return result;
737 });
737 });
738 try {
738 try {
739 p.Join();
739 p.Join();
740 } catch (TargetInvocationException err) {
740 } catch (TargetInvocationException err) {
741 Assert.IsTrue(err.InnerException is OperationCanceledException);
741 Assert.IsTrue(err.InnerException is OperationCanceledException);
742 }
742 }
743 }
743 }
744
744
745 [TestMethod]
745 [TestMethod]
746 public void ChainedCancel2Test() {
746 public void ChainedCancel2Test() {
747 // ΠΏΡ€ΠΈ ΠΎΡ‚ΠΌΠ΅Π½Π΅ Ρ†Π΅ΠΏΠΎΡ‡ΠΊΠΈ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠΉ, Π²Π»ΠΎΠΆΠ΅Π½Π½Ρ‹Π΅ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ Ρ‚Π°ΠΊΠΆΠ΅ Π΄ΠΎΠ»ΠΆΠ½Ρ‹ ΠΎΡ‚ΠΌΠ΅Π½ΡΡ‚ΡŒΡΡ
747 // ΠΏΡ€ΠΈ ΠΎΡ‚ΠΌΠ΅Π½Π΅ Ρ†Π΅ΠΏΠΎΡ‡ΠΊΠΈ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠΉ, Π²Π»ΠΎΠΆΠ΅Π½Π½Ρ‹Π΅ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ Ρ‚Π°ΠΊΠΆΠ΅ Π΄ΠΎΠ»ΠΆΠ½Ρ‹ ΠΎΡ‚ΠΌΠ΅Π½ΡΡ‚ΡŒΡΡ
748 var pSurvive = new Promise<bool>();
748 var pSurvive = new Promise<bool>();
749 var hemStarted = new Signal();
749 var hemStarted = new Signal();
750 var p = PromiseHelper
750 var p = PromiseHelper
751 .Sleep(1, "Hi, HAL!")
751 .Sleep(1, "Hi, HAL!")
752 .Chain(() => {
752 .Chain(() => {
753 hemStarted.Set();
753 hemStarted.Set();
754 // запускаСм Π΄Π²Π΅ асинхронныС ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ
754 // запускаСм Π΄Π²Π΅ асинхронныС ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ
755 var result = PromiseHelper
755 var result = PromiseHelper
756 .Sleep(2000, "HEM ENABLED!!!")
756 .Sleep(2000, "HEM ENABLED!!!")
757 .Then(() => pSurvive.Resolve(false));
757 .Then(() => pSurvive.Resolve(false));
758
758
759 result
759 result
760 .On(() => pSurvive.Resolve(true), PromiseEventType.Cancelled);
760 .On(() => pSurvive.Resolve(true), PromiseEventType.Cancelled);
761
761
762 return result;
762 return result;
763 });
763 });
764
764
765 hemStarted.Wait();
765 hemStarted.Wait();
766 p.Cancel();
766 p.Cancel();
767
767
768 try {
768 try {
769 p.Join();
769 p.Join();
770 Assert.Fail();
770 Assert.Fail();
771 } catch (OperationCanceledException) {
771 } catch (OperationCanceledException) {
772 }
772 }
773 Assert.IsTrue(pSurvive.Join());
773 Assert.IsTrue(pSurvive.Join());
774 }
774 }
775
775
776 [TestMethod]
776 [TestMethod]
777 public void SharedLockTest() {
777 public void SharedLockTest() {
778 var l = new SharedLock();
778 var l = new SharedLock();
779 int shared = 0;
779 int shared = 0;
780 int exclusive = 0;
780 int exclusive = 0;
781 var s1 = new Signal();
781 var s1 = new Signal();
782 var log = new AsyncQueue<string>();
782 var log = new AsyncQueue<string>();
783
783
784 try {
784 try {
785 AsyncPool.RunThread(
785 AsyncPool.RunThread(
786 () => {
786 () => {
787 log.Enqueue("Reader #1 started");
787 log.Enqueue("Reader #1 started");
788 try {
788 try {
789 l.LockShared();
789 l.LockShared();
790 log.Enqueue("Reader #1 lock got");
790 log.Enqueue("Reader #1 lock got");
791 if (Interlocked.Increment(ref shared) == 2)
791 if (Interlocked.Increment(ref shared) == 2)
792 s1.Set();
792 s1.Set();
793 s1.Wait();
793 s1.Wait();
794 log.Enqueue("Reader #1 finished");
794 log.Enqueue("Reader #1 finished");
795 Interlocked.Decrement(ref shared);
795 Interlocked.Decrement(ref shared);
796 } finally {
796 } finally {
797 l.Release();
797 l.Release();
798 log.Enqueue("Reader #1 lock released");
798 log.Enqueue("Reader #1 lock released");
799 }
799 }
800 },
800 },
801 () => {
801 () => {
802 log.Enqueue("Reader #2 started");
802 log.Enqueue("Reader #2 started");
803
803
804 try {
804 try {
805 l.LockShared();
805 l.LockShared();
806 log.Enqueue("Reader #2 lock got");
806 log.Enqueue("Reader #2 lock got");
807
807
808 if (Interlocked.Increment(ref shared) == 2)
808 if (Interlocked.Increment(ref shared) == 2)
809 s1.Set();
809 s1.Set();
810 s1.Wait();
810 s1.Wait();
811 log.Enqueue("Reader #2 upgrading to writer");
811 log.Enqueue("Reader #2 upgrading to writer");
812 Interlocked.Decrement(ref shared);
812 Interlocked.Decrement(ref shared);
813 l.Upgrade();
813 l.Upgrade();
814 log.Enqueue("Reader #2 upgraded");
814 log.Enqueue("Reader #2 upgraded");
815
815
816 Assert.AreEqual(1, Interlocked.Increment(ref exclusive));
816 Assert.AreEqual(1, Interlocked.Increment(ref exclusive));
817 Assert.AreEqual(0, shared);
817 Assert.AreEqual(0, shared);
818 log.Enqueue("Reader #2 finished");
818 log.Enqueue("Reader #2 finished");
819 Interlocked.Decrement(ref exclusive);
819 Interlocked.Decrement(ref exclusive);
820 } finally {
820 } finally {
821 l.Release();
821 l.Release();
822 log.Enqueue("Reader #2 lock released");
822 log.Enqueue("Reader #2 lock released");
823 }
823 }
824 },
824 },
825 () => {
825 () => {
826 log.Enqueue("Writer #1 started");
826 log.Enqueue("Writer #1 started");
827 try {
827 try {
828 l.LockExclusive();
828 l.LockExclusive();
829 log.Enqueue("Writer #1 got the lock");
829 log.Enqueue("Writer #1 got the lock");
830 Assert.AreEqual(1, Interlocked.Increment(ref exclusive));
830 Assert.AreEqual(1, Interlocked.Increment(ref exclusive));
831 Interlocked.Decrement(ref exclusive);
831 Interlocked.Decrement(ref exclusive);
832 log.Enqueue("Writer #1 is finished");
832 log.Enqueue("Writer #1 is finished");
833 } finally {
833 } finally {
834 l.Release();
834 l.Release();
835 log.Enqueue("Writer #1 lock released");
835 log.Enqueue("Writer #1 lock released");
836 }
836 }
837 }
837 }
838 ).Bundle().Join(1000);
838 ).Bundle().Join(1000);
839 log.Enqueue("Done");
839 log.Enqueue("Done");
840 } catch(Exception error) {
840 } catch(Exception error) {
841 log.Enqueue(error.Message);
841 log.Enqueue(error.Message);
842 throw;
842 throw;
843 } finally {
843 } finally {
844 foreach (var m in log)
844 foreach (var m in log)
845 Console.WriteLine(m);
845 Console.WriteLine(m);
846 }
846 }
847 }
847 }
848
849 #if NET_4_5
850
851 [TestMethod]
852 public async void TaskInteropTest() {
853 var promise = new Promise<int>();
854 promise.Resolve(10);
855 var res = await promise;
856
857 Assert.AreEqual(10, res);
858 }
859
860 #endif
848 }
861 }
849 }
862 }
850
863
@@ -1,67 +1,68
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 <ProductVersion>8.0.30703</ProductVersion>
6 <ProductVersion>8.0.30703</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{2BD05F84-E067-4B87-9477-FDC2676A21C6}</ProjectGuid>
8 <ProjectGuid>{2BD05F84-E067-4B87-9477-FDC2676A21C6}</ProjectGuid>
9 <OutputType>Library</OutputType>
9 <OutputType>Library</OutputType>
10 <RootNamespace>Implab.Test</RootNamespace>
10 <RootNamespace>Implab.Test</RootNamespace>
11 <AssemblyName>Implab.Test</AssemblyName>
11 <AssemblyName>Implab.Test</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 <ReleaseVersion>0.2</ReleaseVersion>
13 </PropertyGroup>
14 </PropertyGroup>
14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <DebugSymbols>true</DebugSymbols>
16 <DebugSymbols>true</DebugSymbols>
16 <DebugType>full</DebugType>
17 <DebugType>full</DebugType>
17 <Optimize>false</Optimize>
18 <Optimize>false</Optimize>
18 <OutputPath>bin\Debug</OutputPath>
19 <OutputPath>bin\Debug</OutputPath>
19 <DefineConstants>DEBUG;MONO</DefineConstants>
20 <DefineConstants>DEBUG;MONO</DefineConstants>
20 <ErrorReport>prompt</ErrorReport>
21 <ErrorReport>prompt</ErrorReport>
21 <WarningLevel>4</WarningLevel>
22 <WarningLevel>4</WarningLevel>
22 <ConsolePause>false</ConsolePause>
23 <ConsolePause>false</ConsolePause>
23 </PropertyGroup>
24 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <Optimize>true</Optimize>
26 <Optimize>true</Optimize>
26 <OutputPath>bin\Release</OutputPath>
27 <OutputPath>bin\Release</OutputPath>
27 <ErrorReport>prompt</ErrorReport>
28 <ErrorReport>prompt</ErrorReport>
28 <WarningLevel>4</WarningLevel>
29 <WarningLevel>4</WarningLevel>
29 <ConsolePause>false</ConsolePause>
30 <ConsolePause>false</ConsolePause>
30 <DefineConstants>MONO</DefineConstants>
31 <DefineConstants>MONO</DefineConstants>
31 </PropertyGroup>
32 </PropertyGroup>
32 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
33 <DebugSymbols>true</DebugSymbols>
34 <DebugSymbols>true</DebugSymbols>
34 <DebugType>full</DebugType>
35 <DebugType>full</DebugType>
35 <Optimize>false</Optimize>
36 <Optimize>false</Optimize>
36 <OutputPath>bin\Debug</OutputPath>
37 <OutputPath>bin\Debug</OutputPath>
37 <DefineConstants>DEBUG;TRACE;NET_4_5;MONO</DefineConstants>
38 <DefineConstants>DEBUG;TRACE;NET_4_5;MONO</DefineConstants>
38 <ErrorReport>prompt</ErrorReport>
39 <ErrorReport>prompt</ErrorReport>
39 <WarningLevel>4</WarningLevel>
40 <WarningLevel>4</WarningLevel>
40 <ConsolePause>false</ConsolePause>
41 <ConsolePause>false</ConsolePause>
41 </PropertyGroup>
42 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
43 <Optimize>true</Optimize>
44 <Optimize>true</Optimize>
44 <OutputPath>bin\Release</OutputPath>
45 <OutputPath>bin\Release</OutputPath>
45 <DefineConstants>NET_4_5;MONO</DefineConstants>
46 <DefineConstants>NET_4_5;MONO</DefineConstants>
46 <ErrorReport>prompt</ErrorReport>
47 <ErrorReport>prompt</ErrorReport>
47 <WarningLevel>4</WarningLevel>
48 <WarningLevel>4</WarningLevel>
48 <ConsolePause>false</ConsolePause>
49 <ConsolePause>false</ConsolePause>
49 </PropertyGroup>
50 </PropertyGroup>
50 <ItemGroup>
51 <ItemGroup>
51 <Reference Include="System" />
52 <Reference Include="System" />
52 <Reference Include="nunit.framework" />
53 <Reference Include="nunit.framework" />
53 </ItemGroup>
54 </ItemGroup>
54 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
55 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
55 <ItemGroup>
56 <ItemGroup>
56 <Compile Include="AsyncTests.cs" />
57 <Compile Include="AsyncTests.cs" />
57 <Compile Include="PromiseHelper.cs" />
58 <Compile Include="PromiseHelper.cs" />
58 <Compile Include="Properties\AssemblyInfo.cs" />
59 <Compile Include="Properties\AssemblyInfo.cs" />
59 <Compile Include="CancelationTests.cs" />
60 <Compile Include="CancelationTests.cs" />
60 </ItemGroup>
61 </ItemGroup>
61 <ItemGroup>
62 <ItemGroup>
62 <ProjectReference Include="..\Implab\Implab.csproj">
63 <ProjectReference Include="..\Implab\Implab.csproj">
63 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
64 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
64 <Name>Implab</Name>
65 <Name>Implab</Name>
65 </ProjectReference>
66 </ProjectReference>
66 </ItemGroup>
67 </ItemGroup>
67 </Project> No newline at end of file
68 </Project>
@@ -1,289 +1,290
1 ο»Ώ
1 ο»Ώ
2 Microsoft Visual Studio Solution File, Format Version 11.00
2 Microsoft Visual Studio Solution File, Format Version 11.00
3 # Visual Studio 2010
3 # Visual Studio 2010
4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab", "Implab\Implab.csproj", "{F550F1F8-8746-4AD0-9614-855F4C4B7F05}"
4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab", "Implab\Implab.csproj", "{F550F1F8-8746-4AD0-9614-855F4C4B7F05}"
5 EndProject
5 EndProject
6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE8D8D18-437A-445C-B662-4C2CE79A76F6}"
6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CE8D8D18-437A-445C-B662-4C2CE79A76F6}"
7 ProjectSection(SolutionItems) = preProject
7 ProjectSection(SolutionItems) = preProject
8 Implab.vsmdi = Implab.vsmdi
8 Implab.vsmdi = Implab.vsmdi
9 Local.testsettings = Local.testsettings
9 Local.testsettings = Local.testsettings
10 TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
10 TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings
11 EndProjectSection
11 EndProjectSection
12 EndProject
12 EndProject
13 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}"
13 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Fx", "Implab.Fx\Implab.Fx.csproj", "{06E706F8-6881-43EB-927E-FFC503AF6ABC}"
14 EndProject
14 EndProject
15 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BCA337C3-BFDC-4825-BBDB-E6D467E4E452}"
15 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{BCA337C3-BFDC-4825-BBDB-E6D467E4E452}"
16 EndProject
16 EndProject
17 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Test.mono", "Implab.Test\Implab.Test.mono.csproj", "{2BD05F84-E067-4B87-9477-FDC2676A21C6}"
17 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Implab.Test.mono", "Implab.Test\Implab.Test.mono.csproj", "{2BD05F84-E067-4B87-9477-FDC2676A21C6}"
18 EndProject
18 EndProject
19 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoPlay", "MonoPlay\MonoPlay.csproj", "{15DD7123-D504-4627-8B4F-D00C7F04D033}"
19 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoPlay", "MonoPlay\MonoPlay.csproj", "{15DD7123-D504-4627-8B4F-D00C7F04D033}"
20 EndProject
20 EndProject
21 Global
21 Global
22 GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 Debug|Any CPU = Debug|Any CPU
23 Debug|Any CPU = Debug|Any CPU
24 Release|Any CPU = Release|Any CPU
24 Release|Any CPU = Release|Any CPU
25 Debug 4.5|Any CPU = Debug 4.5|Any CPU
25 Debug 4.5|Any CPU = Debug 4.5|Any CPU
26 Release 4.5|Any CPU = Release 4.5|Any CPU
26 Release 4.5|Any CPU = Release 4.5|Any CPU
27 EndGlobalSection
27 EndGlobalSection
28 GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
29 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
30 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
30 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
31 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
33 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
34 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
34 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
35 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU
36 {06E706F8-6881-43EB-927E-FFC503AF6ABC}.Release|Any CPU.Build.0 = Release|Any CPU
37 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug 4.5|Any CPU.ActiveCfg = Debug|Any CPU
37 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug 4.5|Any CPU.ActiveCfg = Debug|Any CPU
38 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug 4.5|Any CPU.Build.0 = Debug|Any CPU
38 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug 4.5|Any CPU.Build.0 = Debug|Any CPU
39 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release 4.5|Any CPU.ActiveCfg = Release|Any CPU
41 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release 4.5|Any CPU.ActiveCfg = Release|Any CPU
42 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release 4.5|Any CPU.Build.0 = Release|Any CPU
42 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release 4.5|Any CPU.Build.0 = Release|Any CPU
43 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release|Any CPU.Build.0 = Release|Any CPU
44 {15DD7123-D504-4627-8B4F-D00C7F04D033}.Release|Any CPU.Build.0 = Release|Any CPU
45 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
45 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
46 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
46 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
47 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
49 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
49 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
50 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
50 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
51 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.Build.0 = Release|Any CPU
52 {2BD05F84-E067-4B87-9477-FDC2676A21C6}.Release|Any CPU.Build.0 = Release|Any CPU
53 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
53 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
54 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
54 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
55 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
57 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
57 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
58 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
58 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
59 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
59 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.Build.0 = Release|Any CPU
60 {F550F1F8-8746-4AD0-9614-855F4C4B7F05}.Release|Any CPU.Build.0 = Release|Any CPU
61 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
61 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
62 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
62 {2F31E405-E267-4195-A05D-574093C21209}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
63 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 {2F31E405-E267-4195-A05D-574093C21209}.Debug|Any CPU.Build.0 = Debug|Any CPU
65 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
65 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
66 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
66 {2F31E405-E267-4195-A05D-574093C21209}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
67 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU
68 {2F31E405-E267-4195-A05D-574093C21209}.Release|Any CPU.Build.0 = Release|Any CPU
69 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
69 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.ActiveCfg = Debug 4.5|Any CPU
70 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
70 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug 4.5|Any CPU.Build.0 = Debug 4.5|Any CPU
71 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
72 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
73 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
73 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.ActiveCfg = Release 4.5|Any CPU
74 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
74 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release 4.5|Any CPU.Build.0 = Release 4.5|Any CPU
75 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
75 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
76 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.Build.0 = Release|Any CPU
76 {63F92C0C-61BF-48C0-A377-8D67C3C661D0}.Release|Any CPU.Build.0 = Release|Any CPU
77 EndGlobalSection
77 EndGlobalSection
78 GlobalSection(NestedProjects) = preSolution
78 GlobalSection(NestedProjects) = preSolution
79 {2BD05F84-E067-4B87-9477-FDC2676A21C6} = {BCA337C3-BFDC-4825-BBDB-E6D467E4E452}
79 {2BD05F84-E067-4B87-9477-FDC2676A21C6} = {BCA337C3-BFDC-4825-BBDB-E6D467E4E452}
80 EndGlobalSection
80 EndGlobalSection
81 GlobalSection(MonoDevelopProperties) = preSolution
81 GlobalSection(MonoDevelopProperties) = preSolution
82 StartupItem = MonoPlay\MonoPlay.csproj
83 Policies = $0
82 Policies = $0
84 $0.CSharpFormattingPolicy = $1
83 $0.CSharpFormattingPolicy = $1
85 $1.IndentSwitchBody = True
84 $1.IndentSwitchBody = True
86 $1.NamespaceBraceStyle = EndOfLine
85 $1.NamespaceBraceStyle = EndOfLine
87 $1.ClassBraceStyle = EndOfLine
86 $1.ClassBraceStyle = EndOfLine
88 $1.InterfaceBraceStyle = EndOfLine
87 $1.InterfaceBraceStyle = EndOfLine
89 $1.StructBraceStyle = EndOfLine
88 $1.StructBraceStyle = EndOfLine
90 $1.EnumBraceStyle = EndOfLine
89 $1.EnumBraceStyle = EndOfLine
91 $1.MethodBraceStyle = EndOfLine
90 $1.MethodBraceStyle = EndOfLine
92 $1.ConstructorBraceStyle = EndOfLine
91 $1.ConstructorBraceStyle = EndOfLine
93 $1.DestructorBraceStyle = EndOfLine
92 $1.DestructorBraceStyle = EndOfLine
94 $1.BeforeMethodDeclarationParentheses = False
93 $1.BeforeMethodDeclarationParentheses = False
95 $1.BeforeMethodCallParentheses = False
94 $1.BeforeMethodCallParentheses = False
96 $1.BeforeConstructorDeclarationParentheses = False
95 $1.BeforeConstructorDeclarationParentheses = False
97 $1.NewLineBeforeConstructorInitializerColon = NewLine
96 $1.NewLineBeforeConstructorInitializerColon = NewLine
98 $1.NewLineAfterConstructorInitializerColon = SameLine
97 $1.NewLineAfterConstructorInitializerColon = SameLine
99 $1.BeforeIndexerDeclarationBracket = False
98 $1.BeforeIndexerDeclarationBracket = False
100 $1.BeforeDelegateDeclarationParentheses = False
99 $1.BeforeDelegateDeclarationParentheses = False
101 $1.NewParentheses = False
100 $1.NewParentheses = False
102 $1.SpacesBeforeBrackets = False
101 $1.SpacesBeforeBrackets = False
103 $1.inheritsSet = Mono
102 $1.inheritsSet = Mono
104 $1.inheritsScope = text/x-csharp
103 $1.inheritsScope = text/x-csharp
105 $1.scope = text/x-csharp
104 $1.scope = text/x-csharp
106 $0.TextStylePolicy = $2
105 $0.TextStylePolicy = $2
107 $2.FileWidth = 120
106 $2.FileWidth = 120
108 $2.EolMarker = Unix
107 $2.EolMarker = Unix
109 $2.inheritsSet = VisualStudio
108 $2.inheritsSet = VisualStudio
110 $2.inheritsScope = text/plain
109 $2.inheritsScope = text/plain
111 $2.scope = text/x-csharp
110 $2.scope = text/x-csharp
112 $0.DotNetNamingPolicy = $3
111 $0.DotNetNamingPolicy = $3
113 $3.DirectoryNamespaceAssociation = PrefixedHierarchical
112 $3.DirectoryNamespaceAssociation = PrefixedHierarchical
114 $3.ResourceNamePolicy = MSBuild
113 $3.ResourceNamePolicy = MSBuild
115 $0.TextStylePolicy = $4
114 $0.TextStylePolicy = $4
116 $4.FileWidth = 120
115 $4.FileWidth = 120
117 $4.TabsToSpaces = False
116 $4.TabsToSpaces = False
118 $4.inheritsSet = VisualStudio
117 $4.inheritsSet = VisualStudio
119 $4.inheritsScope = text/plain
118 $4.inheritsScope = text/plain
120 $4.scope = application/xml
119 $4.scope = application/xml
121 $0.XmlFormattingPolicy = $5
120 $0.XmlFormattingPolicy = $5
122 $5.inheritsSet = Mono
121 $5.inheritsSet = Mono
123 $5.inheritsScope = application/xml
122 $5.inheritsScope = application/xml
124 $5.scope = application/xml
123 $5.scope = application/xml
125 $0.TextStylePolicy = $6
124 $0.TextStylePolicy = $6
126 $6.FileWidth = 120
125 $6.FileWidth = 120
127 $6.TabsToSpaces = False
126 $6.TabsToSpaces = False
128 $6.inheritsSet = VisualStudio
127 $6.inheritsSet = VisualStudio
129 $6.inheritsScope = text/plain
128 $6.inheritsScope = text/plain
130 $6.scope = text/plain
129 $6.scope = text/plain
131 $0.NameConventionPolicy = $7
130 $0.NameConventionPolicy = $7
132 $7.Rules = $8
131 $7.Rules = $8
133 $8.NamingRule = $9
132 $8.NamingRule = $9
134 $9.Name = Namespaces
133 $9.Name = Namespaces
135 $9.AffectedEntity = Namespace
134 $9.AffectedEntity = Namespace
136 $9.VisibilityMask = VisibilityMask
135 $9.VisibilityMask = VisibilityMask
137 $9.NamingStyle = PascalCase
136 $9.NamingStyle = PascalCase
138 $9.IncludeInstanceMembers = True
137 $9.IncludeInstanceMembers = True
139 $9.IncludeStaticEntities = True
138 $9.IncludeStaticEntities = True
140 $8.NamingRule = $10
139 $8.NamingRule = $10
141 $10.Name = Types
140 $10.Name = Types
142 $10.AffectedEntity = Class, Struct, Enum, Delegate
141 $10.AffectedEntity = Class, Struct, Enum, Delegate
143 $10.VisibilityMask = VisibilityMask
142 $10.VisibilityMask = VisibilityMask
144 $10.NamingStyle = PascalCase
143 $10.NamingStyle = PascalCase
145 $10.IncludeInstanceMembers = True
144 $10.IncludeInstanceMembers = True
146 $10.IncludeStaticEntities = True
145 $10.IncludeStaticEntities = True
147 $8.NamingRule = $11
146 $8.NamingRule = $11
148 $11.Name = Interfaces
147 $11.Name = Interfaces
149 $11.RequiredPrefixes = $12
148 $11.RequiredPrefixes = $12
150 $12.String = I
149 $12.String = I
151 $11.AffectedEntity = Interface
150 $11.AffectedEntity = Interface
152 $11.VisibilityMask = VisibilityMask
151 $11.VisibilityMask = VisibilityMask
153 $11.NamingStyle = PascalCase
152 $11.NamingStyle = PascalCase
154 $11.IncludeInstanceMembers = True
153 $11.IncludeInstanceMembers = True
155 $11.IncludeStaticEntities = True
154 $11.IncludeStaticEntities = True
156 $8.NamingRule = $13
155 $8.NamingRule = $13
157 $13.Name = Attributes
156 $13.Name = Attributes
158 $13.RequiredSuffixes = $14
157 $13.RequiredSuffixes = $14
159 $14.String = Attribute
158 $14.String = Attribute
160 $13.AffectedEntity = CustomAttributes
159 $13.AffectedEntity = CustomAttributes
161 $13.VisibilityMask = VisibilityMask
160 $13.VisibilityMask = VisibilityMask
162 $13.NamingStyle = PascalCase
161 $13.NamingStyle = PascalCase
163 $13.IncludeInstanceMembers = True
162 $13.IncludeInstanceMembers = True
164 $13.IncludeStaticEntities = True
163 $13.IncludeStaticEntities = True
165 $8.NamingRule = $15
164 $8.NamingRule = $15
166 $15.Name = Event Arguments
165 $15.Name = Event Arguments
167 $15.RequiredSuffixes = $16
166 $15.RequiredSuffixes = $16
168 $16.String = EventArgs
167 $16.String = EventArgs
169 $15.AffectedEntity = CustomEventArgs
168 $15.AffectedEntity = CustomEventArgs
170 $15.VisibilityMask = VisibilityMask
169 $15.VisibilityMask = VisibilityMask
171 $15.NamingStyle = PascalCase
170 $15.NamingStyle = PascalCase
172 $15.IncludeInstanceMembers = True
171 $15.IncludeInstanceMembers = True
173 $15.IncludeStaticEntities = True
172 $15.IncludeStaticEntities = True
174 $8.NamingRule = $17
173 $8.NamingRule = $17
175 $17.Name = Exceptions
174 $17.Name = Exceptions
176 $17.RequiredSuffixes = $18
175 $17.RequiredSuffixes = $18
177 $18.String = Exception
176 $18.String = Exception
178 $17.AffectedEntity = CustomExceptions
177 $17.AffectedEntity = CustomExceptions
179 $17.VisibilityMask = VisibilityMask
178 $17.VisibilityMask = VisibilityMask
180 $17.NamingStyle = PascalCase
179 $17.NamingStyle = PascalCase
181 $17.IncludeInstanceMembers = True
180 $17.IncludeInstanceMembers = True
182 $17.IncludeStaticEntities = True
181 $17.IncludeStaticEntities = True
183 $8.NamingRule = $19
182 $8.NamingRule = $19
184 $19.Name = Methods
183 $19.Name = Methods
185 $19.AffectedEntity = Methods
184 $19.AffectedEntity = Methods
186 $19.VisibilityMask = VisibilityMask
185 $19.VisibilityMask = VisibilityMask
187 $19.NamingStyle = PascalCase
186 $19.NamingStyle = PascalCase
188 $19.IncludeInstanceMembers = True
187 $19.IncludeInstanceMembers = True
189 $19.IncludeStaticEntities = True
188 $19.IncludeStaticEntities = True
190 $8.NamingRule = $20
189 $8.NamingRule = $20
191 $20.Name = Static Readonly Fields
190 $20.Name = Static Readonly Fields
192 $20.AffectedEntity = ReadonlyField
191 $20.AffectedEntity = ReadonlyField
193 $20.VisibilityMask = Internal, Protected, Public
192 $20.VisibilityMask = Internal, Protected, Public
194 $20.NamingStyle = PascalCase
193 $20.NamingStyle = PascalCase
195 $20.IncludeInstanceMembers = False
194 $20.IncludeInstanceMembers = False
196 $20.IncludeStaticEntities = True
195 $20.IncludeStaticEntities = True
197 $8.NamingRule = $21
196 $8.NamingRule = $21
198 $21.Name = Fields (Non Private)
197 $21.Name = Fields (Non Private)
199 $21.AffectedEntity = Field
198 $21.AffectedEntity = Field
200 $21.VisibilityMask = Internal, Public
199 $21.VisibilityMask = Internal, Public
201 $21.NamingStyle = CamelCase
200 $21.NamingStyle = CamelCase
202 $21.IncludeInstanceMembers = True
201 $21.IncludeInstanceMembers = True
203 $21.IncludeStaticEntities = True
202 $21.IncludeStaticEntities = True
204 $8.NamingRule = $22
203 $8.NamingRule = $22
205 $22.Name = ReadOnly Fields (Non Private)
204 $22.Name = ReadOnly Fields (Non Private)
206 $22.AffectedEntity = ReadonlyField
205 $22.AffectedEntity = ReadonlyField
207 $22.VisibilityMask = Internal, Public
206 $22.VisibilityMask = Internal, Public
208 $22.NamingStyle = CamelCase
207 $22.NamingStyle = CamelCase
209 $22.IncludeInstanceMembers = True
208 $22.IncludeInstanceMembers = True
210 $22.IncludeStaticEntities = False
209 $22.IncludeStaticEntities = False
211 $8.NamingRule = $23
210 $8.NamingRule = $23
212 $23.Name = Fields (Private)
211 $23.Name = Fields (Private)
213 $23.RequiredPrefixes = $24
212 $23.RequiredPrefixes = $24
214 $24.String = m_
213 $24.String = m_
215 $23.AffectedEntity = Field, ReadonlyField
214 $23.AffectedEntity = Field, ReadonlyField
216 $23.VisibilityMask = Private, Protected
215 $23.VisibilityMask = Private, Protected
217 $23.NamingStyle = CamelCase
216 $23.NamingStyle = CamelCase
218 $23.IncludeInstanceMembers = True
217 $23.IncludeInstanceMembers = True
219 $23.IncludeStaticEntities = False
218 $23.IncludeStaticEntities = False
220 $8.NamingRule = $25
219 $8.NamingRule = $25
221 $25.Name = Static Fields (Private)
220 $25.Name = Static Fields (Private)
222 $25.RequiredPrefixes = $26
221 $25.RequiredPrefixes = $26
223 $26.String = _
222 $26.String = _
224 $25.AffectedEntity = Field
223 $25.AffectedEntity = Field
225 $25.VisibilityMask = Private
224 $25.VisibilityMask = Private
226 $25.NamingStyle = CamelCase
225 $25.NamingStyle = CamelCase
227 $25.IncludeInstanceMembers = False
226 $25.IncludeInstanceMembers = False
228 $25.IncludeStaticEntities = True
227 $25.IncludeStaticEntities = True
229 $8.NamingRule = $27
228 $8.NamingRule = $27
230 $27.Name = ReadOnly Fields (Private)
229 $27.Name = ReadOnly Fields (Private)
231 $27.RequiredPrefixes = $28
230 $27.RequiredPrefixes = $28
232 $28.String = m_
231 $28.String = m_
233 $27.AffectedEntity = ReadonlyField
232 $27.AffectedEntity = ReadonlyField
234 $27.VisibilityMask = Private, Protected
233 $27.VisibilityMask = Private, Protected
235 $27.NamingStyle = CamelCase
234 $27.NamingStyle = CamelCase
236 $27.IncludeInstanceMembers = True
235 $27.IncludeInstanceMembers = True
237 $27.IncludeStaticEntities = False
236 $27.IncludeStaticEntities = False
238 $8.NamingRule = $29
237 $8.NamingRule = $29
239 $29.Name = Constant Fields
238 $29.Name = Constant Fields
240 $29.AffectedEntity = ConstantField
239 $29.AffectedEntity = ConstantField
241 $29.VisibilityMask = VisibilityMask
240 $29.VisibilityMask = VisibilityMask
242 $29.NamingStyle = AllUpper
241 $29.NamingStyle = AllUpper
243 $29.IncludeInstanceMembers = True
242 $29.IncludeInstanceMembers = True
244 $29.IncludeStaticEntities = True
243 $29.IncludeStaticEntities = True
245 $8.NamingRule = $30
244 $8.NamingRule = $30
246 $30.Name = Properties
245 $30.Name = Properties
247 $30.AffectedEntity = Property
246 $30.AffectedEntity = Property
248 $30.VisibilityMask = VisibilityMask
247 $30.VisibilityMask = VisibilityMask
249 $30.NamingStyle = PascalCase
248 $30.NamingStyle = PascalCase
250 $30.IncludeInstanceMembers = True
249 $30.IncludeInstanceMembers = True
251 $30.IncludeStaticEntities = True
250 $30.IncludeStaticEntities = True
252 $8.NamingRule = $31
251 $8.NamingRule = $31
253 $31.Name = Events
252 $31.Name = Events
254 $31.AffectedEntity = Event
253 $31.AffectedEntity = Event
255 $31.VisibilityMask = VisibilityMask
254 $31.VisibilityMask = VisibilityMask
256 $31.NamingStyle = PascalCase
255 $31.NamingStyle = PascalCase
257 $31.IncludeInstanceMembers = True
256 $31.IncludeInstanceMembers = True
258 $31.IncludeStaticEntities = True
257 $31.IncludeStaticEntities = True
259 $8.NamingRule = $32
258 $8.NamingRule = $32
260 $32.Name = Enum Members
259 $32.Name = Enum Members
261 $32.AffectedEntity = EnumMember
260 $32.AffectedEntity = EnumMember
262 $32.VisibilityMask = VisibilityMask
261 $32.VisibilityMask = VisibilityMask
263 $32.NamingStyle = PascalCase
262 $32.NamingStyle = PascalCase
264 $32.IncludeInstanceMembers = True
263 $32.IncludeInstanceMembers = True
265 $32.IncludeStaticEntities = True
264 $32.IncludeStaticEntities = True
266 $8.NamingRule = $33
265 $8.NamingRule = $33
267 $33.Name = Parameters
266 $33.Name = Parameters
268 $33.AffectedEntity = Parameter, LocalVariable
267 $33.AffectedEntity = Parameter, LocalVariable
269 $33.VisibilityMask = VisibilityMask
268 $33.VisibilityMask = VisibilityMask
270 $33.NamingStyle = CamelCase
269 $33.NamingStyle = CamelCase
271 $33.IncludeInstanceMembers = True
270 $33.IncludeInstanceMembers = True
272 $33.IncludeStaticEntities = True
271 $33.IncludeStaticEntities = True
273 $8.NamingRule = $34
272 $8.NamingRule = $34
274 $34.Name = Type Parameters
273 $34.Name = Type Parameters
275 $34.RequiredPrefixes = $35
274 $34.RequiredPrefixes = $35
276 $35.String = T
275 $35.String = T
277 $34.AffectedEntity = TypeParameter
276 $34.AffectedEntity = TypeParameter
278 $34.VisibilityMask = VisibilityMask
277 $34.VisibilityMask = VisibilityMask
279 $34.NamingStyle = PascalCase
278 $34.NamingStyle = PascalCase
280 $34.IncludeInstanceMembers = True
279 $34.IncludeInstanceMembers = True
281 $34.IncludeStaticEntities = True
280 $34.IncludeStaticEntities = True
281 version = 0.2
282 StartupItem = MonoPlay\MonoPlay.csproj
282 EndGlobalSection
283 EndGlobalSection
283 GlobalSection(TestCaseManagementSettings) = postSolution
284 GlobalSection(TestCaseManagementSettings) = postSolution
284 CategoryFile = Implab.vsmdi
285 CategoryFile = Implab.vsmdi
285 EndGlobalSection
286 EndGlobalSection
286 GlobalSection(SolutionProperties) = preSolution
287 GlobalSection(SolutionProperties) = preSolution
287 HideSolutionNode = FALSE
288 HideSolutionNode = FALSE
288 EndGlobalSection
289 EndGlobalSection
289 EndGlobal
290 EndGlobal
@@ -1,106 +1,66
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 {
6 namespace Implab {
7 public interface IPromise: ICancellable {
7 public interface IPromise: ICancellable {
8
8
9 /// <summary>
9 /// <summary>
10 /// Π’ΠΈΠΏ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π°, ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌΠΎΠ³ΠΎ Ρ‡Π΅Ρ€Π΅Π· Π΄Π°Π½Π½ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅.
10 /// Π’ΠΈΠΏ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π°, ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅ΠΌΠΎΠ³ΠΎ Ρ‡Π΅Ρ€Π΅Π· Π΄Π°Π½Π½ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅.
11 /// </summary>
11 /// </summary>
12 Type PromiseType { get; }
12 Type PromiseType { get; }
13
13
14 /// <summary>
14 /// <summary>
15 /// ΠžΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ являСтся Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Ρ‹ΠΌ, Π»ΠΈΠ±ΠΎ ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ, Π»ΠΈΠ±ΠΎ с ошибкой, Π»ΠΈΠ±ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½ΠΎ.
15 /// ΠžΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ являСтся Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½Ρ‹ΠΌ, Π»ΠΈΠ±ΠΎ ΡƒΡΠΏΠ΅ΡˆΠ½ΠΎ, Π»ΠΈΠ±ΠΎ с ошибкой, Π»ΠΈΠ±ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½ΠΎ.
16 /// </summary>
16 /// </summary>
17 bool IsResolved { get; }
17 bool IsResolved { get; }
18
18
19 /// <summary>
19 /// <summary>
20 /// ΠžΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π±Ρ‹Π»ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½ΠΎ.
20 /// ΠžΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ Π±Ρ‹Π»ΠΎ ΠΎΡ‚ΠΌΠ΅Π½Π΅Π½ΠΎ.
21 /// </summary>
21 /// </summary>
22 bool IsCancelled { get; }
22 bool IsCancelled { get; }
23
23
24 /// <summary>
24 /// <summary>
25 /// Π˜ΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ возникшСС Π² Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π΅ выполнСния обСщания, Π»ΠΈΠ±ΠΎ ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π° ΠΎΡ‚ΠΌΠ΅Π½Ρ‹.
25 /// Π˜ΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ возникшСС Π² Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Π΅ выполнСния обСщания, Π»ΠΈΠ±ΠΎ ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π° ΠΎΡ‚ΠΌΠ΅Π½Ρ‹.
26 /// </summary>
26 /// </summary>
27 Exception Error { get; }
27 Exception Error { get; }
28
28
29 /// <summary>
29 /// <summary>
30 /// Creates a new promise dependend on the current one and resolved on
31 /// executing the specified handlers.
32 /// </summary>
33 /// <param name="success">The handler called on the successful promise completion.</param>
34 /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
35 /// <param name="cancel">The handler is called in case of promise cancellation.</param>
36 /// <returns>The newly created dependant promise.</returns>
37 /// <remarks>
38 /// <para>
39 /// If the success handler is specified the dependend promise will be resolved after the handler is
40 /// executed and the dependent promise will be linked to the current one, i.e. the cancellation
41 /// of the dependent property will lead to the cancellation of the current promise. If the
42 /// success handler isn't specified the dependent promise will not be linked to and
43 /// will not be resolved after the successfull resolution of the current one.
44 /// </para>
45 /// <para>
46 /// When the error handler is specified, the exception raised during the current promise completion
47 /// will be passed to it as the parameter. If the error handler returns without raising an
48 /// exception then the dependant promise will be resolved successfully, otherwise the exception
49 /// raised by the handler will be transmitted to the dependent promise. If the handler wants
50 /// to passthrough the original exception it needs to wrap the exception with
51 /// the <see cref="PromiseTransientException"/>. The handler may raise <see cref="OperationCanceledException"/>
52 /// to cancel the dependant promise, the innner exception specifies the reason why the promise
53 /// is canceled.
54 /// </para>
55 /// <para>
56 /// If the cancelation handler is specified and the current promise is cancelled then the dependent
57 /// promise will be resolved after the handler is executed. If the cancelation handler raises the
58 /// exception it will be passed to the dependent promise.
59 /// </para>
60 /// </remarks>
61 /* IPromise Then(Action success, Action<Exception> error, Action<Exception> cancel);
62 IPromise Then(Action success, Action<Exception> error);
63 IPromise Then(Action success);
64
65 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error, Func<Exception, IPromise> cancel);
66 IPromise Chain(Func<IPromise> chained, Func<Exception, IPromise> error);
67 IPromise Chain(Func<IPromise> chained);*/
68
69 /// <summary>
70 /// Adds specified listeners to the current promise.
30 /// Adds specified listeners to the current promise.
71 /// </summary>
31 /// </summary>
72 /// <param name="success">The handler called on the successful promise completion.</param>
32 /// <param name="success">The handler called on the successful promise completion.</param>
73 /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
33 /// <param name="error">The handler is called if an error while completing the promise occurred.</param>
74 /// <param name="cancel">The handler is called in case of promise cancellation.</param>
34 /// <param name="cancel">The handler is called in case of promise cancellation.</param>
75 /// <returns>The current promise.</returns>
35 /// <returns>The current promise.</returns>
76 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel);
36 IPromise On(Action success, Action<Exception> error, Action<Exception> cancel);
77 IPromise On(Action success, Action<Exception> error);
37 IPromise On(Action success, Action<Exception> error);
78 IPromise On(Action success);
38 IPromise On(Action success);
79
39
80 /// <summary>
40 /// <summary>
81 /// Adds specified listeners to the current promise.
41 /// Adds specified listeners to the current promise.
82 /// </summary>
42 /// </summary>
83 /// <param name="handler">The handler called on the specified events.</param>
43 /// <param name="handler">The handler called on the specified events.</param>
84 /// <param name = "events">The combination of flags denoting the events for which the
44 /// <param name = "events">The combination of flags denoting the events for which the
85 /// handler shoud be called.</param>
45 /// handler shoud be called.</param>
86 /// <returns>The current promise.</returns>
46 /// <returns>The current promise.</returns>
87 IPromise On(Action handler, PromiseEventType events);
47 IPromise On(Action handler, PromiseEventType events);
88
48
89 /// <summary>
49 /// <summary>
90 /// ΠŸΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΡƒΠ΅Ρ‚ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ обСщания ΠΊ Π·Π°Π΄Π°Π½Π½ΠΎΠΌΡƒ Ρ‚ΠΈΠΏΡƒ ΠΈ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π½ΠΎΠ²ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅.
50 /// ΠŸΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΡƒΠ΅Ρ‚ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ обСщания ΠΊ Π·Π°Π΄Π°Π½Π½ΠΎΠΌΡƒ Ρ‚ΠΈΠΏΡƒ ΠΈ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π½ΠΎΠ²ΠΎΠ΅ ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅.
91 /// </summary>
51 /// </summary>
92 IPromise<T> Cast<T>();
52 IPromise<T> Cast<T>();
93
53
94 /// <summary>
54 /// <summary>
95 /// Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΠΎΡ‚ΠΎΠΊ с ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ΠΌ.
55 /// Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΠΎΡ‚ΠΎΠΊ с ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ΠΌ.
96 /// </summary>
56 /// </summary>
97 void Join();
57 void Join();
98 /// <summary>
58 /// <summary>
99 /// Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΠΎΡ‚ΠΎΠΊ с ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ΠΌ.
59 /// Π‘ΠΈΠ½Ρ…Ρ€ΠΎΠ½ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΠΎΡ‚ΠΎΠΊ с ΠΎΠ±Π΅Ρ‰Π°Π½ΠΈΠ΅ΠΌ.
100 /// </summary>
60 /// </summary>
101 /// <param name="timeout">ВрСмя оТидания, ΠΏΠΎ Π΅Π³ΠΎ ΠΈΡΡ‚Π΅Ρ‡Π΅Π½ΠΈΡŽ Π²ΠΎΠ·Π½ΠΈΠΊΠ½Π΅Ρ‚ ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅.</param>
61 /// <param name="timeout">ВрСмя оТидания, ΠΏΠΎ Π΅Π³ΠΎ ΠΈΡΡ‚Π΅Ρ‡Π΅Π½ΠΈΡŽ Π²ΠΎΠ·Π½ΠΈΠΊΠ½Π΅Ρ‚ ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅.</param>
102 /// <exception cref="TimeoutException">ΠŸΡ€Π΅Π²Ρ‹ΡˆΠ΅Π½ΠΎ врСмя оТидания.</exception>
62 /// <exception cref="TimeoutException">ΠŸΡ€Π΅Π²Ρ‹ΡˆΠ΅Π½ΠΎ врСмя оТидания.</exception>
103 void Join(int timeout);
63 void Join(int timeout);
104
64
105 }
65 }
106 }
66 }
@@ -1,248 +1,255
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 <ProductVersion>8.0.30703</ProductVersion>
11 <SchemaVersion>2.0</SchemaVersion>
12 <ReleaseVersion>0.2</ReleaseVersion>
13 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10 </PropertyGroup>
14 </PropertyGroup>
11 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
12 <DebugSymbols>true</DebugSymbols>
16 <DebugSymbols>true</DebugSymbols>
13 <DebugType>full</DebugType>
17 <DebugType>full</DebugType>
14 <Optimize>false</Optimize>
18 <Optimize>false</Optimize>
15 <OutputPath>bin\Debug</OutputPath>
19 <OutputPath>bin\Debug</OutputPath>
16 <DefineConstants>TRACE;DEBUG;</DefineConstants>
20 <DefineConstants>TRACE;DEBUG;</DefineConstants>
17 <ErrorReport>prompt</ErrorReport>
21 <ErrorReport>prompt</ErrorReport>
18 <WarningLevel>4</WarningLevel>
22 <WarningLevel>4</WarningLevel>
19 <ConsolePause>false</ConsolePause>
23 <ConsolePause>false</ConsolePause>
20 <RunCodeAnalysis>true</RunCodeAnalysis>
24 <RunCodeAnalysis>true</RunCodeAnalysis>
21 </PropertyGroup>
25 </PropertyGroup>
22 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23 <DebugType>full</DebugType>
27 <DebugType>full</DebugType>
24 <Optimize>true</Optimize>
28 <Optimize>true</Optimize>
25 <OutputPath>bin\Release</OutputPath>
29 <OutputPath>bin\Release</OutputPath>
26 <ErrorReport>prompt</ErrorReport>
30 <ErrorReport>prompt</ErrorReport>
27 <WarningLevel>4</WarningLevel>
31 <WarningLevel>4</WarningLevel>
28 <ConsolePause>false</ConsolePause>
32 <ConsolePause>false</ConsolePause>
29 </PropertyGroup>
33 </PropertyGroup>
30 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug 4.5|AnyCPU' ">
31 <DebugSymbols>true</DebugSymbols>
35 <DebugSymbols>true</DebugSymbols>
32 <DebugType>full</DebugType>
36 <DebugType>full</DebugType>
33 <Optimize>false</Optimize>
37 <Optimize>false</Optimize>
34 <OutputPath>bin\Debug</OutputPath>
38 <OutputPath>bin\Debug</OutputPath>
35 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
39 <DefineConstants>TRACE;DEBUG;NET_4_5</DefineConstants>
36 <ErrorReport>prompt</ErrorReport>
40 <ErrorReport>prompt</ErrorReport>
37 <WarningLevel>4</WarningLevel>
41 <WarningLevel>4</WarningLevel>
38 <RunCodeAnalysis>true</RunCodeAnalysis>
42 <RunCodeAnalysis>true</RunCodeAnalysis>
39 <ConsolePause>false</ConsolePause>
43 <ConsolePause>false</ConsolePause>
40 </PropertyGroup>
44 </PropertyGroup>
41 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release 4.5|AnyCPU' ">
42 <Optimize>true</Optimize>
46 <Optimize>true</Optimize>
43 <OutputPath>bin\Release</OutputPath>
47 <OutputPath>bin\Release</OutputPath>
44 <ErrorReport>prompt</ErrorReport>
48 <ErrorReport>prompt</ErrorReport>
45 <WarningLevel>4</WarningLevel>
49 <WarningLevel>4</WarningLevel>
46 <ConsolePause>false</ConsolePause>
50 <ConsolePause>false</ConsolePause>
47 <DefineConstants>NET_4_5</DefineConstants>
51 <DefineConstants>NET_4_5</DefineConstants>
48 </PropertyGroup>
52 </PropertyGroup>
49 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
53 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'DebugMono|AnyCPU' ">
50 <DebugSymbols>true</DebugSymbols>
54 <DebugSymbols>true</DebugSymbols>
51 <DebugType>full</DebugType>
55 <DebugType>full</DebugType>
52 <Optimize>false</Optimize>
56 <Optimize>false</Optimize>
53 <OutputPath>bin\Debug</OutputPath>
57 <OutputPath>bin\Debug</OutputPath>
54 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
58 <DefineConstants>TRACE;DEBUG;NET_4_5;MONO</DefineConstants>
55 <ErrorReport>prompt</ErrorReport>
59 <ErrorReport>prompt</ErrorReport>
56 <WarningLevel>4</WarningLevel>
60 <WarningLevel>4</WarningLevel>
57 <RunCodeAnalysis>true</RunCodeAnalysis>
61 <RunCodeAnalysis>true</RunCodeAnalysis>
58 <ConsolePause>false</ConsolePause>
62 <ConsolePause>false</ConsolePause>
59 </PropertyGroup>
63 </PropertyGroup>
60 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
64 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseMono|AnyCPU' ">
61 <Optimize>true</Optimize>
65 <Optimize>true</Optimize>
62 <OutputPath>bin\Release</OutputPath>
66 <OutputPath>bin\Release</OutputPath>
63 <DefineConstants>NET_4_5;MONO;</DefineConstants>
67 <DefineConstants>NET_4_5;MONO;</DefineConstants>
64 <ErrorReport>prompt</ErrorReport>
68 <ErrorReport>prompt</ErrorReport>
65 <WarningLevel>4</WarningLevel>
69 <WarningLevel>4</WarningLevel>
66 <ConsolePause>false</ConsolePause>
70 <ConsolePause>false</ConsolePause>
67 </PropertyGroup>
71 </PropertyGroup>
68 <ItemGroup>
72 <ItemGroup>
69 <Reference Include="System" />
73 <Reference Include="System" />
70 <Reference Include="System.Xml" />
74 <Reference Include="System.Xml" />
75 <Reference Include="mscorlib" />
71 </ItemGroup>
76 </ItemGroup>
72 <ItemGroup>
77 <ItemGroup>
73 <Compile Include="Component.cs" />
78 <Compile Include="Component.cs" />
74 <Compile Include="CustomEqualityComparer.cs" />
79 <Compile Include="CustomEqualityComparer.cs" />
75 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
80 <Compile Include="Diagnostics\ConsoleTraceListener.cs" />
76 <Compile Include="Diagnostics\EventText.cs" />
81 <Compile Include="Diagnostics\EventText.cs" />
77 <Compile Include="Diagnostics\LogChannel.cs" />
82 <Compile Include="Diagnostics\LogChannel.cs" />
78 <Compile Include="Diagnostics\LogicalOperation.cs" />
83 <Compile Include="Diagnostics\LogicalOperation.cs" />
79 <Compile Include="Diagnostics\TextFileListener.cs" />
84 <Compile Include="Diagnostics\TextFileListener.cs" />
80 <Compile Include="Diagnostics\TraceLog.cs" />
85 <Compile Include="Diagnostics\TraceLog.cs" />
81 <Compile Include="Diagnostics\TraceEvent.cs" />
86 <Compile Include="Diagnostics\TraceEvent.cs" />
82 <Compile Include="Diagnostics\TraceEventType.cs" />
87 <Compile Include="Diagnostics\TraceEventType.cs" />
83 <Compile Include="Disposable.cs" />
88 <Compile Include="Disposable.cs" />
84 <Compile Include="ICancellable.cs" />
89 <Compile Include="ICancellable.cs" />
85 <Compile Include="IProgressHandler.cs" />
90 <Compile Include="IProgressHandler.cs" />
86 <Compile Include="IProgressNotifier.cs" />
91 <Compile Include="IProgressNotifier.cs" />
87 <Compile Include="IPromiseT.cs" />
92 <Compile Include="IPromiseT.cs" />
88 <Compile Include="IPromise.cs" />
93 <Compile Include="IPromise.cs" />
89 <Compile Include="IServiceLocator.cs" />
94 <Compile Include="IServiceLocator.cs" />
90 <Compile Include="ITaskController.cs" />
95 <Compile Include="ITaskController.cs" />
91 <Compile Include="JSON\JSONElementContext.cs" />
96 <Compile Include="JSON\JSONElementContext.cs" />
92 <Compile Include="JSON\JSONElementType.cs" />
97 <Compile Include="JSON\JSONElementType.cs" />
93 <Compile Include="JSON\JSONGrammar.cs" />
98 <Compile Include="JSON\JSONGrammar.cs" />
94 <Compile Include="JSON\JSONParser.cs" />
99 <Compile Include="JSON\JSONParser.cs" />
95 <Compile Include="JSON\JSONScanner.cs" />
100 <Compile Include="JSON\JSONScanner.cs" />
96 <Compile Include="JSON\JsonTokenType.cs" />
101 <Compile Include="JSON\JsonTokenType.cs" />
97 <Compile Include="JSON\JSONWriter.cs" />
102 <Compile Include="JSON\JSONWriter.cs" />
98 <Compile Include="JSON\JSONXmlReader.cs" />
103 <Compile Include="JSON\JSONXmlReader.cs" />
99 <Compile Include="JSON\JSONXmlReaderOptions.cs" />
104 <Compile Include="JSON\JSONXmlReaderOptions.cs" />
100 <Compile Include="JSON\StringTranslator.cs" />
105 <Compile Include="JSON\StringTranslator.cs" />
101 <Compile Include="Parallels\DispatchPool.cs" />
106 <Compile Include="Parallels\DispatchPool.cs" />
102 <Compile Include="Parallels\ArrayTraits.cs" />
107 <Compile Include="Parallels\ArrayTraits.cs" />
103 <Compile Include="Parallels\MTQueue.cs" />
108 <Compile Include="Parallels\MTQueue.cs" />
104 <Compile Include="Parallels\WorkerPool.cs" />
109 <Compile Include="Parallels\WorkerPool.cs" />
105 <Compile Include="Parsing\Alphabet.cs" />
110 <Compile Include="Parsing\Alphabet.cs" />
106 <Compile Include="Parsing\AlphabetBase.cs" />
111 <Compile Include="Parsing\AlphabetBase.cs" />
107 <Compile Include="Parsing\AltToken.cs" />
112 <Compile Include="Parsing\AltToken.cs" />
108 <Compile Include="Parsing\BinaryToken.cs" />
113 <Compile Include="Parsing\BinaryToken.cs" />
109 <Compile Include="Parsing\CatToken.cs" />
114 <Compile Include="Parsing\CatToken.cs" />
110 <Compile Include="Parsing\CDFADefinition.cs" />
115 <Compile Include="Parsing\CDFADefinition.cs" />
111 <Compile Include="Parsing\DFABuilder.cs" />
116 <Compile Include="Parsing\DFABuilder.cs" />
112 <Compile Include="Parsing\DFADefinitionBase.cs" />
117 <Compile Include="Parsing\DFADefinitionBase.cs" />
113 <Compile Include="Parsing\DFAStateDescriptor.cs" />
118 <Compile Include="Parsing\DFAStateDescriptor.cs" />
114 <Compile Include="Parsing\DFAutomaton.cs" />
119 <Compile Include="Parsing\DFAutomaton.cs" />
115 <Compile Include="Parsing\EDFADefinition.cs" />
120 <Compile Include="Parsing\EDFADefinition.cs" />
116 <Compile Include="Parsing\EmptyToken.cs" />
121 <Compile Include="Parsing\EmptyToken.cs" />
117 <Compile Include="Parsing\EndToken.cs" />
122 <Compile Include="Parsing\EndToken.cs" />
118 <Compile Include="Parsing\EnumAlphabet.cs" />
123 <Compile Include="Parsing\EnumAlphabet.cs" />
119 <Compile Include="Parsing\Grammar.cs" />
124 <Compile Include="Parsing\Grammar.cs" />
120 <Compile Include="Parsing\IAlphabet.cs" />
125 <Compile Include="Parsing\IAlphabet.cs" />
121 <Compile Include="Parsing\IDFADefinition.cs" />
126 <Compile Include="Parsing\IDFADefinition.cs" />
122 <Compile Include="Parsing\IVisitor.cs" />
127 <Compile Include="Parsing\IVisitor.cs" />
123 <Compile Include="Parsing\ParserException.cs" />
128 <Compile Include="Parsing\ParserException.cs" />
124 <Compile Include="Parsing\Scanner.cs" />
129 <Compile Include="Parsing\Scanner.cs" />
125 <Compile Include="Parsing\StarToken.cs" />
130 <Compile Include="Parsing\StarToken.cs" />
126 <Compile Include="Parsing\SymbolToken.cs" />
131 <Compile Include="Parsing\SymbolToken.cs" />
127 <Compile Include="Parsing\Token.cs" />
132 <Compile Include="Parsing\Token.cs" />
128 <Compile Include="ServiceLocator.cs" />
133 <Compile Include="ServiceLocator.cs" />
129 <Compile Include="TaskController.cs" />
134 <Compile Include="TaskController.cs" />
130 <Compile Include="ProgressInitEventArgs.cs" />
135 <Compile Include="ProgressInitEventArgs.cs" />
131 <Compile Include="Properties\AssemblyInfo.cs" />
136 <Compile Include="Properties\AssemblyInfo.cs" />
132 <Compile Include="Parallels\AsyncPool.cs" />
137 <Compile Include="Parallels\AsyncPool.cs" />
133 <Compile Include="Safe.cs" />
138 <Compile Include="Safe.cs" />
134 <Compile Include="ValueEventArgs.cs" />
139 <Compile Include="ValueEventArgs.cs" />
135 <Compile Include="PromiseExtensions.cs" />
140 <Compile Include="PromiseExtensions.cs" />
136 <Compile Include="SyncContextPromise.cs" />
141 <Compile Include="SyncContextPromise.cs" />
137 <Compile Include="Diagnostics\OperationContext.cs" />
142 <Compile Include="Diagnostics\OperationContext.cs" />
138 <Compile Include="Diagnostics\TraceContext.cs" />
143 <Compile Include="Diagnostics\TraceContext.cs" />
139 <Compile Include="Diagnostics\LogEventArgs.cs" />
144 <Compile Include="Diagnostics\LogEventArgs.cs" />
140 <Compile Include="Diagnostics\LogEventArgsT.cs" />
145 <Compile Include="Diagnostics\LogEventArgsT.cs" />
141 <Compile Include="Diagnostics\Extensions.cs" />
146 <Compile Include="Diagnostics\Extensions.cs" />
142 <Compile Include="IComponentContainer.cs" />
147 <Compile Include="IComponentContainer.cs" />
143 <Compile Include="PromiseEventType.cs" />
148 <Compile Include="PromiseEventType.cs" />
144 <Compile Include="ComponentContainer.cs" />
149 <Compile Include="ComponentContainer.cs" />
145 <Compile Include="DisposablePool.cs" />
150 <Compile Include="DisposablePool.cs" />
146 <Compile Include="ObjectPool.cs" />
151 <Compile Include="ObjectPool.cs" />
147 <Compile Include="Parallels\AsyncQueue.cs" />
152 <Compile Include="Parallels\AsyncQueue.cs" />
148 <Compile Include="PromiseT.cs" />
153 <Compile Include="PromiseT.cs" />
149 <Compile Include="IDeferred.cs" />
154 <Compile Include="IDeferred.cs" />
150 <Compile Include="IDeferredT.cs" />
155 <Compile Include="IDeferredT.cs" />
151 <Compile Include="Promise.cs" />
156 <Compile Include="Promise.cs" />
152 <Compile Include="PromiseTransientException.cs" />
157 <Compile Include="PromiseTransientException.cs" />
153 <Compile Include="Parallels\Signal.cs" />
158 <Compile Include="Parallels\Signal.cs" />
154 <Compile Include="Parallels\SharedLock.cs" />
159 <Compile Include="Parallels\SharedLock.cs" />
155 <Compile Include="Diagnostics\ILogWriter.cs" />
160 <Compile Include="Diagnostics\ILogWriter.cs" />
156 <Compile Include="Diagnostics\ListenerBase.cs" />
161 <Compile Include="Diagnostics\ListenerBase.cs" />
157 <Compile Include="Parallels\BlockingQueue.cs" />
162 <Compile Include="Parallels\BlockingQueue.cs" />
158 <Compile Include="AbstractEvent.cs" />
163 <Compile Include="AbstractEvent.cs" />
159 <Compile Include="AbstractPromise.cs" />
164 <Compile Include="AbstractPromise.cs" />
160 <Compile Include="AbstractPromiseT.cs" />
165 <Compile Include="AbstractPromiseT.cs" />
161 <Compile Include="FuncTask.cs" />
166 <Compile Include="FuncTask.cs" />
162 <Compile Include="FuncTaskBase.cs" />
167 <Compile Include="FuncTaskBase.cs" />
163 <Compile Include="FuncTaskT.cs" />
168 <Compile Include="FuncTaskT.cs" />
164 <Compile Include="ActionChainTaskBase.cs" />
169 <Compile Include="ActionChainTaskBase.cs" />
165 <Compile Include="ActionChainTask.cs" />
170 <Compile Include="ActionChainTask.cs" />
166 <Compile Include="ActionChainTaskT.cs" />
171 <Compile Include="ActionChainTaskT.cs" />
167 <Compile Include="FuncChainTaskBase.cs" />
172 <Compile Include="FuncChainTaskBase.cs" />
168 <Compile Include="FuncChainTask.cs" />
173 <Compile Include="FuncChainTask.cs" />
169 <Compile Include="FuncChainTaskT.cs" />
174 <Compile Include="FuncChainTaskT.cs" />
170 <Compile Include="ActionTaskBase.cs" />
175 <Compile Include="ActionTaskBase.cs" />
171 <Compile Include="ActionTask.cs" />
176 <Compile Include="ActionTask.cs" />
172 <Compile Include="ActionTaskT.cs" />
177 <Compile Include="ActionTaskT.cs" />
173 <Compile Include="ICancellationToken.cs" />
178 <Compile Include="ICancellationToken.cs" />
174 <Compile Include="SuccessPromise.cs" />
179 <Compile Include="SuccessPromise.cs" />
175 <Compile Include="SuccessPromiseT.cs" />
180 <Compile Include="SuccessPromiseT.cs" />
181 <Compile Include="PromiseAwaiterT.cs" />
182 <Compile Include="PromiseAwaiter.cs" />
176 </ItemGroup>
183 </ItemGroup>
177 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
184 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
178 <ItemGroup />
185 <ItemGroup />
179 <ProjectExtensions>
186 <ProjectExtensions>
180 <MonoDevelop>
187 <MonoDevelop>
181 <Properties>
188 <Properties>
182 <Policies>
189 <Policies>
183 <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" />
190 <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" />
184 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
191 <TextStylePolicy FileWidth="120" EolMarker="Unix" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
185 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
192 <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="MSBuild" />
186 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
193 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="application/xml" />
187 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
194 <XmlFormattingPolicy inheritsSet="Mono" inheritsScope="application/xml" scope="application/xml" />
188 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
195 <TextStylePolicy FileWidth="120" TabsToSpaces="False" inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/plain" />
189 <NameConventionPolicy>
196 <NameConventionPolicy>
190 <Rules>
197 <Rules>
191 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
198 <NamingRule Name="Namespaces" AffectedEntity="Namespace" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
192 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
199 <NamingRule Name="Types" AffectedEntity="Class, Struct, Enum, Delegate" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
193 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
200 <NamingRule Name="Interfaces" AffectedEntity="Interface" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
194 <RequiredPrefixes>
201 <RequiredPrefixes>
195 <String>I</String>
202 <String>I</String>
196 </RequiredPrefixes>
203 </RequiredPrefixes>
197 </NamingRule>
204 </NamingRule>
198 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
205 <NamingRule Name="Attributes" AffectedEntity="CustomAttributes" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
199 <RequiredSuffixes>
206 <RequiredSuffixes>
200 <String>Attribute</String>
207 <String>Attribute</String>
201 </RequiredSuffixes>
208 </RequiredSuffixes>
202 </NamingRule>
209 </NamingRule>
203 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
210 <NamingRule Name="Event Arguments" AffectedEntity="CustomEventArgs" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
204 <RequiredSuffixes>
211 <RequiredSuffixes>
205 <String>EventArgs</String>
212 <String>EventArgs</String>
206 </RequiredSuffixes>
213 </RequiredSuffixes>
207 </NamingRule>
214 </NamingRule>
208 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
215 <NamingRule Name="Exceptions" AffectedEntity="CustomExceptions" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
209 <RequiredSuffixes>
216 <RequiredSuffixes>
210 <String>Exception</String>
217 <String>Exception</String>
211 </RequiredSuffixes>
218 </RequiredSuffixes>
212 </NamingRule>
219 </NamingRule>
213 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
220 <NamingRule Name="Methods" AffectedEntity="Methods" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
214 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
221 <NamingRule Name="Static Readonly Fields" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Protected, Public" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True" />
215 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
222 <NamingRule Name="Fields (Non Private)" AffectedEntity="Field" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
216 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
223 <NamingRule Name="ReadOnly Fields (Non Private)" AffectedEntity="ReadonlyField" VisibilityMask="Internal, Public" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False" />
217 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
224 <NamingRule Name="Fields (Private)" AffectedEntity="Field, ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
218 <RequiredPrefixes>
225 <RequiredPrefixes>
219 <String>m_</String>
226 <String>m_</String>
220 </RequiredPrefixes>
227 </RequiredPrefixes>
221 </NamingRule>
228 </NamingRule>
222 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
229 <NamingRule Name="Static Fields (Private)" AffectedEntity="Field" VisibilityMask="Private" NamingStyle="CamelCase" IncludeInstanceMembers="False" IncludeStaticEntities="True">
223 <RequiredPrefixes>
230 <RequiredPrefixes>
224 <String>_</String>
231 <String>_</String>
225 </RequiredPrefixes>
232 </RequiredPrefixes>
226 </NamingRule>
233 </NamingRule>
227 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
234 <NamingRule Name="ReadOnly Fields (Private)" AffectedEntity="ReadonlyField" VisibilityMask="Private, Protected" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="False">
228 <RequiredPrefixes>
235 <RequiredPrefixes>
229 <String>m_</String>
236 <String>m_</String>
230 </RequiredPrefixes>
237 </RequiredPrefixes>
231 </NamingRule>
238 </NamingRule>
232 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
239 <NamingRule Name="Constant Fields" AffectedEntity="ConstantField" VisibilityMask="VisibilityMask" NamingStyle="AllUpper" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
233 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
240 <NamingRule Name="Properties" AffectedEntity="Property" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
234 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
241 <NamingRule Name="Events" AffectedEntity="Event" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
235 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
242 <NamingRule Name="Enum Members" AffectedEntity="EnumMember" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
236 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
243 <NamingRule Name="Parameters" AffectedEntity="Parameter, LocalVariable" VisibilityMask="VisibilityMask" NamingStyle="CamelCase" IncludeInstanceMembers="True" IncludeStaticEntities="True" />
237 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
244 <NamingRule Name="Type Parameters" AffectedEntity="TypeParameter" VisibilityMask="VisibilityMask" NamingStyle="PascalCase" IncludeInstanceMembers="True" IncludeStaticEntities="True">
238 <RequiredPrefixes>
245 <RequiredPrefixes>
239 <String>T</String>
246 <String>T</String>
240 </RequiredPrefixes>
247 </RequiredPrefixes>
241 </NamingRule>
248 </NamingRule>
242 </Rules>
249 </Rules>
243 </NameConventionPolicy>
250 </NameConventionPolicy>
244 </Policies>
251 </Policies>
245 </Properties>
252 </Properties>
246 </MonoDevelop>
253 </MonoDevelop>
247 </ProjectExtensions>
254 </ProjectExtensions>
248 </Project> No newline at end of file
255 </Project>
@@ -1,302 +1,299
1 using System.Threading;
1 using System.Threading;
2 using System;
2 using System;
3 using Implab.Diagnostics;
3 using Implab.Diagnostics;
4 using System.Collections.Generic;
4 using System.Collections.Generic;
5
5
6
6
7 #if NET_4_5
7 #if NET_4_5
8 using System.Threading.Tasks;
8 using System.Threading.Tasks;
9 #endif
9 #endif
10
10
11 namespace Implab {
11 namespace Implab {
12 public static class PromiseExtensions {
12 public static class PromiseExtensions {
13 public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) {
13 public static IPromise<T> DispatchToCurrentContext<T>(this IPromise<T> that) {
14 Safe.ArgumentNotNull(that, "that");
14 Safe.ArgumentNotNull(that, "that");
15 var context = SynchronizationContext.Current;
15 var context = SynchronizationContext.Current;
16 if (context == null)
16 if (context == null)
17 return that;
17 return that;
18
18
19 var p = new SyncContextPromise<T>(context);
19 var p = new SyncContextPromise<T>(context);
20 p.On(that.Cancel, PromiseEventType.Cancelled);
20 p.On(that.Cancel, PromiseEventType.Cancelled);
21
21
22 that.On(
22 that.On(
23 p.Resolve,
23 p.Resolve,
24 p.Reject,
24 p.Reject,
25 p.Cancel
25 p.Cancel
26 );
26 );
27 return p;
27 return p;
28 }
28 }
29
29
30 public static IPromise<T> DispatchToContext<T>(this IPromise<T> that, SynchronizationContext context) {
30 public static IPromise<T> DispatchToContext<T>(this IPromise<T> that, SynchronizationContext context) {
31 Safe.ArgumentNotNull(that, "that");
31 Safe.ArgumentNotNull(that, "that");
32 Safe.ArgumentNotNull(context, "context");
32 Safe.ArgumentNotNull(context, "context");
33
33
34 var p = new SyncContextPromise<T>(context);
34 var p = new SyncContextPromise<T>(context);
35 p.On(that.Cancel, PromiseEventType.Cancelled);
35 p.On(that.Cancel, PromiseEventType.Cancelled);
36
36
37
37
38 that.On(
38 that.On(
39 p.Resolve,
39 p.Resolve,
40 p.Reject,
40 p.Reject,
41 p.Cancel
41 p.Cancel
42 );
42 );
43 return p;
43 return p;
44 }
44 }
45
45
46 /// <summary>
46 /// <summary>
47 /// Ensures the dispatched.
47 /// Ensures the dispatched.
48 /// </summary>
48 /// </summary>
49 /// <returns>The dispatched.</returns>
49 /// <returns>The dispatched.</returns>
50 /// <param name="that">That.</param>
50 /// <param name="that">That.</param>
51 /// <param name="head">Head.</param>
51 /// <param name="head">Head.</param>
52 /// <param name="cleanup">Cleanup.</param>
52 /// <param name="cleanup">Cleanup.</param>
53 /// <typeparam name="TPromise">The 1st type parameter.</typeparam>
53 /// <typeparam name="TPromise">The 1st type parameter.</typeparam>
54 /// <typeparam name="T">The 2nd type parameter.</typeparam>
54 /// <typeparam name="T">The 2nd type parameter.</typeparam>
55 public static TPromise EnsureDispatched<TPromise,T>(this TPromise that, IPromise<T> head, Action<T> cleanup) where TPromise : IPromise{
55 public static TPromise EnsureDispatched<TPromise,T>(this TPromise that, IPromise<T> head, Action<T> cleanup) where TPromise : IPromise{
56 Safe.ArgumentNotNull(that, "that");
56 Safe.ArgumentNotNull(that, "that");
57 Safe.ArgumentNotNull(head, "head");
57 Safe.ArgumentNotNull(head, "head");
58
58
59 that.On(() => head.On(cleanup), PromiseEventType.Cancelled);
59 that.On(() => head.On(cleanup), PromiseEventType.Cancelled);
60
60
61 return that;
61 return that;
62 }
62 }
63
63
64 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) {
64 public static AsyncCallback AsyncCallback<T>(this Promise<T> that, Func<IAsyncResult,T> callback) {
65 Safe.ArgumentNotNull(that, "that");
65 Safe.ArgumentNotNull(that, "that");
66 Safe.ArgumentNotNull(callback, "callback");
66 Safe.ArgumentNotNull(callback, "callback");
67 var op = TraceContext.Instance.CurrentOperation;
67 var op = TraceContext.Instance.CurrentOperation;
68 return ar => {
68 return ar => {
69 TraceContext.Instance.EnterLogicalOperation(op,false);
69 TraceContext.Instance.EnterLogicalOperation(op,false);
70 try {
70 try {
71 that.Resolve(callback(ar));
71 that.Resolve(callback(ar));
72 } catch (Exception err) {
72 } catch (Exception err) {
73 that.Reject(err);
73 that.Reject(err);
74 } finally {
74 } finally {
75 TraceContext.Instance.Leave();
75 TraceContext.Instance.Leave();
76 }
76 }
77 };
77 };
78 }
78 }
79
79
80 static void CancelCallback(object cookie) {
80 static void CancelCallback(object cookie) {
81 ((ICancellable)cookie).Cancel();
81 ((ICancellable)cookie).Cancel();
82 }
82 }
83
83
84 /// <summary>
84 /// <summary>
85 /// Cancells promise after the specified timeout is elapsed.
85 /// Cancells promise after the specified timeout is elapsed.
86 /// </summary>
86 /// </summary>
87 /// <param name="that">The promise to cancel on timeout.</param>
87 /// <param name="that">The promise to cancel on timeout.</param>
88 /// <param name="milliseconds">The timeout in milliseconds.</param>
88 /// <param name="milliseconds">The timeout in milliseconds.</param>
89 /// <typeparam name="TPromise">The 1st type parameter.</typeparam>
89 /// <typeparam name="TPromise">The 1st type parameter.</typeparam>
90 public static TPromise Timeout<TPromise>(this TPromise that, int milliseconds) where TPromise : IPromise {
90 public static TPromise Timeout<TPromise>(this TPromise that, int milliseconds) where TPromise : IPromise {
91 Safe.ArgumentNotNull(that, "that");
91 Safe.ArgumentNotNull(that, "that");
92 var timer = new Timer(CancelCallback, that, milliseconds, -1);
92 var timer = new Timer(CancelCallback, that, milliseconds, -1);
93 that.On(timer.Dispose, PromiseEventType.All);
93 that.On(timer.Dispose, PromiseEventType.All);
94 return that;
94 return that;
95 }
95 }
96
96
97 public static IPromise Bundle(this ICollection<IPromise> that) {
97 public static IPromise Bundle(this ICollection<IPromise> that) {
98 Safe.ArgumentNotNull(that, "that");
98 Safe.ArgumentNotNull(that, "that");
99
99
100 int count = that.Count;
100 int count = that.Count;
101 int errors = 0;
101 int errors = 0;
102 var medium = new Promise();
102 var medium = new Promise();
103
103
104 if (count == 0) {
104 if (count == 0) {
105 medium.Resolve();
105 medium.Resolve();
106 return medium;
106 return medium;
107 }
107 }
108
108
109 medium.On(() => {
109 medium.On(() => {
110 foreach(var p2 in that)
110 foreach(var p2 in that)
111 p2.Cancel();
111 p2.Cancel();
112 }, PromiseEventType.ErrorOrCancel);
112 }, PromiseEventType.ErrorOrCancel);
113
113
114 foreach (var p in that)
114 foreach (var p in that)
115 p.On(
115 p.On(
116 () => {
116 () => {
117 if (Interlocked.Decrement(ref count) == 0)
117 if (Interlocked.Decrement(ref count) == 0)
118 medium.Resolve();
118 medium.Resolve();
119 },
119 },
120 error => {
120 error => {
121 if (Interlocked.Increment(ref errors) == 1)
121 if (Interlocked.Increment(ref errors) == 1)
122 medium.Reject(
122 medium.Reject(
123 new Exception("The dependency promise is failed", error)
123 new Exception("The dependency promise is failed", error)
124 );
124 );
125 },
125 },
126 reason => {
126 reason => {
127 if (Interlocked.Increment(ref errors) == 1)
127 if (Interlocked.Increment(ref errors) == 1)
128 medium.Cancel(
128 medium.Cancel(
129 new Exception("The dependency promise is cancelled")
129 new Exception("The dependency promise is cancelled")
130 );
130 );
131 }
131 }
132 );
132 );
133
133
134 return medium;
134 return medium;
135 }
135 }
136
136
137 public static IPromise<T[]> Bundle<T>(this ICollection<IPromise<T>> that) {
137 public static IPromise<T[]> Bundle<T>(this ICollection<IPromise<T>> that) {
138 Safe.ArgumentNotNull(that, "that");
138 Safe.ArgumentNotNull(that, "that");
139
139
140 int count = that.Count;
140 int count = that.Count;
141 int errors = 0;
141 int errors = 0;
142 var medium = new Promise<T[]>();
142 var medium = new Promise<T[]>();
143 var results = new T[that.Count];
143 var results = new T[that.Count];
144
144
145 medium.On(() => {
145 medium.On(() => {
146 foreach(var p2 in that)
146 foreach(var p2 in that)
147 p2.Cancel();
147 p2.Cancel();
148 }, PromiseEventType.ErrorOrCancel);
148 }, PromiseEventType.ErrorOrCancel);
149
149
150 int i = 0;
150 int i = 0;
151 foreach (var p in that) {
151 foreach (var p in that) {
152 var idx = i;
152 var idx = i;
153 p.On(
153 p.On(
154 x => {
154 x => {
155 results[idx] = x;
155 results[idx] = x;
156 if (Interlocked.Decrement(ref count) == 0)
156 if (Interlocked.Decrement(ref count) == 0)
157 medium.Resolve(results);
157 medium.Resolve(results);
158 },
158 },
159 error => {
159 error => {
160 if (Interlocked.Increment(ref errors) == 1)
160 if (Interlocked.Increment(ref errors) == 1)
161 medium.Reject(
161 medium.Reject(
162 new Exception("The dependency promise is failed", error)
162 new Exception("The dependency promise is failed", error)
163 );
163 );
164 },
164 },
165 reason => {
165 reason => {
166 if (Interlocked.Increment(ref errors) == 1)
166 if (Interlocked.Increment(ref errors) == 1)
167 medium.Cancel(
167 medium.Cancel(
168 new Exception("The dependency promise is cancelled", reason)
168 new Exception("The dependency promise is cancelled", reason)
169 );
169 );
170 }
170 }
171 );
171 );
172 i++;
172 i++;
173 }
173 }
174
174
175 return medium;
175 return medium;
176 }
176 }
177
177
178 public static IPromise Then(this IPromise that, Action success, Action<Exception> error, Action<Exception> cancel) {
178 public static IPromise Then(this IPromise that, Action success, Action<Exception> error, Action<Exception> cancel) {
179 Safe.ArgumentNotNull(that, "that");
179 Safe.ArgumentNotNull(that, "that");
180
180
181 var d = new ActionTask(success, error, cancel, false);
181 var d = new ActionTask(success, error, cancel, false);
182 that.On(d.Resolve, d.Reject, d.CancelOperation);
182 that.On(d.Resolve, d.Reject, d.CancelOperation);
183 if (success != null)
183 if (success != null)
184 d.CancellationRequested(that.Cancel);
184 d.CancellationRequested(that.Cancel);
185 return d;
185 return d;
186 }
186 }
187
187
188 public static IPromise Then(this IPromise that, Action success, Action<Exception> error) {
188 public static IPromise Then(this IPromise that, Action success, Action<Exception> error) {
189 return Then(that, success, error, null);
189 return Then(that, success, error, null);
190 }
190 }
191
191
192 public static IPromise Then(this IPromise that, Action success) {
192 public static IPromise Then(this IPromise that, Action success) {
193 return Then(that, success, null, null);
193 return Then(that, success, null, null);
194 }
194 }
195
195
196 public static IPromise<T> Then<T>(this IPromise that, Func<T> success, Func<Exception, T> error, Func<Exception, T> cancel) {
196 public static IPromise<T> Then<T>(this IPromise that, Func<T> success, Func<Exception, T> error, Func<Exception, T> cancel) {
197 Safe.ArgumentNotNull(that, "that");
197 Safe.ArgumentNotNull(that, "that");
198
198
199 var d = new FuncTask<T>(success, error, cancel, false);
199 var d = new FuncTask<T>(success, error, cancel, false);
200 that.On(d.Resolve, d.Reject, d.CancelOperation);
200 that.On(d.Resolve, d.Reject, d.CancelOperation);
201 if (success != null)
201 if (success != null)
202 d.CancellationRequested(that.Cancel);
202 d.CancellationRequested(that.Cancel);
203 return d;
203 return d;
204 }
204 }
205
205
206 public static IPromise<T> Then<T>(this IPromise that, Func<T> success, Func<Exception, T> error) {
206 public static IPromise<T> Then<T>(this IPromise that, Func<T> success, Func<Exception, T> error) {
207 return Then(that, success, error, null);
207 return Then(that, success, error, null);
208 }
208 }
209
209
210 public static IPromise<T> Then<T>(this IPromise that, Func<T> success) {
210 public static IPromise<T> Then<T>(this IPromise that, Func<T> success) {
211 return Then(that, success, null, null);
211 return Then(that, success, null, null);
212 }
212 }
213
213
214 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success, Func<Exception, T2> error, Func<Exception, T2> cancel) {
214 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success, Func<Exception, T2> error, Func<Exception, T2> cancel) {
215 Safe.ArgumentNotNull(that, "that");
215 Safe.ArgumentNotNull(that, "that");
216 var d = new FuncTask<T,T2>(success, error, cancel, false);
216 var d = new FuncTask<T,T2>(success, error, cancel, false);
217 that.On(d.Resolve, d.Reject, d.CancelOperation);
217 that.On(d.Resolve, d.Reject, d.CancelOperation);
218 if (success != null)
218 if (success != null)
219 d.CancellationRequested(that.Cancel);
219 d.CancellationRequested(that.Cancel);
220 return d;
220 return d;
221 }
221 }
222
222
223 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success, Func<Exception, T2> error) {
223 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success, Func<Exception, T2> error) {
224 return Then(that, success, error, null);
224 return Then(that, success, error, null);
225 }
225 }
226
226
227 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success) {
227 public static IPromise<T2> Then<T, T2>(this IPromise<T> that, Func<T, T2> success) {
228 return Then(that, success, null, null);
228 return Then(that, success, null, null);
229 }
229 }
230
230
231 #region chain traits
231 #region chain traits
232 public static IPromise Chain(this IPromise that, Func<IPromise> success, Func<Exception,IPromise> error, Func<Exception,IPromise> cancel) {
232 public static IPromise Chain(this IPromise that, Func<IPromise> success, Func<Exception,IPromise> error, Func<Exception,IPromise> cancel) {
233 Safe.ArgumentNotNull(that, "that");
233 Safe.ArgumentNotNull(that, "that");
234
234
235 var d = new ActionChainTask(success, error, cancel, false);
235 var d = new ActionChainTask(success, error, cancel, false);
236 that.On(d.Resolve, d.Reject, d.CancelOperation);
236 that.On(d.Resolve, d.Reject, d.CancelOperation);
237 if (success != null)
237 if (success != null)
238 d.CancellationRequested(that.Cancel);
238 d.CancellationRequested(that.Cancel);
239 return d;
239 return d;
240 }
240 }
241
241
242 public static IPromise Chain(this IPromise that, Func<IPromise> success, Func<Exception,IPromise> error) {
242 public static IPromise Chain(this IPromise that, Func<IPromise> success, Func<Exception,IPromise> error) {
243 return Chain(that, success, error, null);
243 return Chain(that, success, error, null);
244 }
244 }
245
245
246 public static IPromise Chain(this IPromise that, Func<IPromise> success) {
246 public static IPromise Chain(this IPromise that, Func<IPromise> success) {
247 return Chain(that, success, null, null);
247 return Chain(that, success, null, null);
248 }
248 }
249
249
250 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success, Func<Exception, IPromise<T>> error, Func<Exception, IPromise<T>> cancel) {
250 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success, Func<Exception, IPromise<T>> error, Func<Exception, IPromise<T>> cancel) {
251 Safe.ArgumentNotNull(that, "that");
251 Safe.ArgumentNotNull(that, "that");
252
252
253 var d = new FuncChainTask<T>(success, error, cancel, false);
253 var d = new FuncChainTask<T>(success, error, cancel, false);
254 that.On(d.Resolve, d.Reject, d.CancelOperation);
254 that.On(d.Resolve, d.Reject, d.CancelOperation);
255 if (success != null)
255 if (success != null)
256 d.CancellationRequested(that.Cancel);
256 d.CancellationRequested(that.Cancel);
257 return d;
257 return d;
258 }
258 }
259
259
260 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success, Func<Exception, IPromise<T>> error) {
260 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success, Func<Exception, IPromise<T>> error) {
261 return Chain(that, success, error, null);
261 return Chain(that, success, error, null);
262 }
262 }
263
263
264 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success) {
264 public static IPromise<T> Chain<T>(this IPromise that, Func<IPromise<T>> success) {
265 return Chain(that, success, null, null);
265 return Chain(that, success, null, null);
266 }
266 }
267
267
268 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success, Func<Exception, IPromise<T2>> error, Func<Exception, IPromise<T2>> cancel) {
268 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success, Func<Exception, IPromise<T2>> error, Func<Exception, IPromise<T2>> cancel) {
269 Safe.ArgumentNotNull(that, "that");
269 Safe.ArgumentNotNull(that, "that");
270 var d = new FuncChainTask<T,T2>(success, error, cancel, false);
270 var d = new FuncChainTask<T,T2>(success, error, cancel, false);
271 that.On(d.Resolve, d.Reject, d.CancelOperation);
271 that.On(d.Resolve, d.Reject, d.CancelOperation);
272 if (success != null)
272 if (success != null)
273 d.CancellationRequested(that.Cancel);
273 d.CancellationRequested(that.Cancel);
274 return d;
274 return d;
275 }
275 }
276
276
277 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success, Func<Exception, IPromise<T2>> error) {
277 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success, Func<Exception, IPromise<T2>> error) {
278 return Chain(that, success, error, null);
278 return Chain(that, success, error, null);
279 }
279 }
280
280
281 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success) {
281 public static IPromise<T2> Chain<T, T2>(this IPromise<T> that, Func<T, IPromise<T2>> success) {
282 return Chain(that, success, null, null);
282 return Chain(that, success, null, null);
283 }
283 }
284
284
285 #endregion
285 #endregion
286
286
287
287
288 #if NET_4_5
288 #if NET_4_5
289
289
290 public static Task<T> GetTask<T>(this IPromise<T> that) {
290 public static PromiseAwaiter<T> GetAwaiter<T>(this IPromise<T> that) {
291 Safe.ArgumentNotNull(that, "that");
291 Safe.ArgumentNotNull(that, "that");
292 var tcs = new TaskCompletionSource<T>();
293
292
294 that.On(tcs.SetResult, tcs.SetException, r => tcs.SetCanceled());
293 return new PromiseAwaiter<T>(that);
295
296 return tcs.Task;
297 }
294 }
298
295
299 #endif
296 #endif
300 }
297 }
301 }
298 }
302
299
@@ -1,46 +1,47
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 <ProductVersion>8.0.30703</ProductVersion>
6 <ProductVersion>8.0.30703</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{15DD7123-D504-4627-8B4F-D00C7F04D033}</ProjectGuid>
8 <ProjectGuid>{15DD7123-D504-4627-8B4F-D00C7F04D033}</ProjectGuid>
9 <OutputType>Exe</OutputType>
9 <OutputType>Exe</OutputType>
10 <RootNamespace>MonoPlay</RootNamespace>
10 <RootNamespace>MonoPlay</RootNamespace>
11 <AssemblyName>MonoPlay</AssemblyName>
11 <AssemblyName>MonoPlay</AssemblyName>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12 <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 <ReleaseVersion>0.2</ReleaseVersion>
13 </PropertyGroup>
14 </PropertyGroup>
14 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15 <DebugSymbols>true</DebugSymbols>
16 <DebugSymbols>true</DebugSymbols>
16 <DebugType>full</DebugType>
17 <DebugType>full</DebugType>
17 <Optimize>false</Optimize>
18 <Optimize>false</Optimize>
18 <OutputPath>bin\Debug</OutputPath>
19 <OutputPath>bin\Debug</OutputPath>
19 <DefineConstants>DEBUG;TRACE;</DefineConstants>
20 <DefineConstants>DEBUG;TRACE;</DefineConstants>
20 <ErrorReport>prompt</ErrorReport>
21 <ErrorReport>prompt</ErrorReport>
21 <WarningLevel>4</WarningLevel>
22 <WarningLevel>4</WarningLevel>
22 <ConsolePause>false</ConsolePause>
23 <ConsolePause>false</ConsolePause>
23 </PropertyGroup>
24 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 <DebugType>full</DebugType>
26 <DebugType>full</DebugType>
26 <Optimize>true</Optimize>
27 <Optimize>true</Optimize>
27 <OutputPath>bin\Release</OutputPath>
28 <OutputPath>bin\Release</OutputPath>
28 <ErrorReport>prompt</ErrorReport>
29 <ErrorReport>prompt</ErrorReport>
29 <WarningLevel>4</WarningLevel>
30 <WarningLevel>4</WarningLevel>
30 <ConsolePause>false</ConsolePause>
31 <ConsolePause>false</ConsolePause>
31 </PropertyGroup>
32 </PropertyGroup>
32 <ItemGroup>
33 <ItemGroup>
33 <Reference Include="System" />
34 <Reference Include="System" />
34 </ItemGroup>
35 </ItemGroup>
35 <ItemGroup>
36 <ItemGroup>
36 <Compile Include="Program.cs" />
37 <Compile Include="Program.cs" />
37 <Compile Include="Properties\AssemblyInfo.cs" />
38 <Compile Include="Properties\AssemblyInfo.cs" />
38 </ItemGroup>
39 </ItemGroup>
39 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
40 <ItemGroup>
41 <ItemGroup>
41 <ProjectReference Include="..\Implab\Implab.csproj">
42 <ProjectReference Include="..\Implab\Implab.csproj">
42 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
43 <Project>{F550F1F8-8746-4AD0-9614-855F4C4B7F05}</Project>
43 <Name>Implab</Name>
44 <Name>Implab</Name>
44 </ProjectReference>
45 </ProjectReference>
45 </ItemGroup>
46 </ItemGroup>
46 </Project> No newline at end of file
47 </Project>
@@ -1,44 +1,41
1 using System;
1 using System;
2 using Implab.Diagnostics;
2 using Implab.Diagnostics;
3 using Implab.Parallels;
3 using Implab.Parallels;
4 using Implab;
4 using Implab;
5 using System.Collections.Generic;
5 using System.Collections.Generic;
6 using System.Collections.Concurrent;
6 using System.Collections.Concurrent;
7 using System.Threading;
7 using System.Threading;
8 using Implab.JSON;
8 using Implab.JSON;
9 using System.IO;
9 using System.IO;
10 using System.Threading.Tasks;
10
11
11 namespace MonoPlay {
12 namespace MonoPlay {
12 class MainClass {
13 class MainClass {
13
14
14
15
15 public static void Main(string[] args) {
16 public static void Main(string[] args) {
16 if (args == null)
17 if (args == null)
17 throw new ArgumentNullException("args");
18 throw new ArgumentNullException("args");
18
19
19 var t1 = Environment.TickCount;
20 var t1 = Environment.TickCount;
20
21
21 for(int i =0; i < 1000000; i++)
22 DoWork().GetAwaiter().GetResult();
22 using (var tw = new StringWriter()) {
23 var jw = new JSONWriter(tw);
24
25 jw.WriteValue("\r\nhere\tvalue\u0002\u0003");
26
27 //Console.WriteLine(tw);
28 }
29
30
31
23
32 var t2 = Environment.TickCount;
24 var t2 = Environment.TickCount;
33 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) );
25 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) );
34
26
35 }
27 }
36
28
37 static void DoTest() {
29 static IPromise<int> DoItem(int x) {
30 return Promise<int>.FromResult(x + 1);
31 }
38
32
39
33 static async Task<int> DoWork() {
40
34 var c = 0;
35 for (int i = 0; i < 10000000; i++)
36 c = await DoItem(c);
37 return c;
41 }
38 }
42
39
43 }
40 }
44 }
41 }
General Comments 0
You need to be logged in to leave comments. Login now