annotate MonoPlay/Program.cs @ 148:e6d4b41f0101 v2

fixed timeout handling in promises
author cin
date Wed, 15 Apr 2015 07:30:20 +0300
parents 706fccb85524
children 3258399cba83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
1 using System;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
2 using Implab.Diagnostics;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
3 using Implab.Parallels;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
4 using Implab;
103
cin
parents: 94
diff changeset
5 using System.Collections.Generic;
cin
parents: 94
diff changeset
6 using System.Collections.Concurrent;
136
e9e7940c7d98 shared locks + tests
cin
parents: 125
diff changeset
7 using System.Threading;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
8
dc4942d09e74 improved tracing
cin
parents:
diff changeset
9 namespace MonoPlay {
dc4942d09e74 improved tracing
cin
parents:
diff changeset
10 class MainClass {
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
11
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
12
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
13 public static void Main(string[] args) {
94
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
14 if (args == null)
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
15 throw new ArgumentNullException("args");
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
16
103
cin
parents: 94
diff changeset
17 var t1 = Environment.TickCount;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
18
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
19 for (int i = 0; i < 10000000; i++) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
20
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
21 var p = new Promise<int>();
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
22 p.On(HandleResult);
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
23 p.Resolve(i);
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
24 }
121
62d2f1e98c4e working version of AsyncQueue and batch operations
cin
parents: 120
diff changeset
25
103
cin
parents: 94
diff changeset
26 var t2 = Environment.TickCount;
125
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
27 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) );
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
28
dc4942d09e74 improved tracing
cin
parents:
diff changeset
29 }
136
e9e7940c7d98 shared locks + tests
cin
parents: 125
diff changeset
30
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
31 static void HandleAction ()
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
32 {
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
33
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
34 }
136
e9e7940c7d98 shared locks + tests
cin
parents: 125
diff changeset
35
145
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
36 static void HandleResult(int x) {
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
37
706fccb85524 RC: cancellation support for promises + tests
cin
parents: 138
diff changeset
38 }
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
39 }
dc4942d09e74 improved tracing
cin
parents:
diff changeset
40 }