@@ -14,7 +14,7 namespace Implab.Diagnostics.Interactive | |||||
14 | TraceForm m_form; |
|
14 | TraceForm m_form; | |
15 |
|
15 | |||
16 | SynchronizationContext m_syncGuiThread; |
|
16 | SynchronizationContext m_syncGuiThread; | |
17 |
readonly Promise |
|
17 | readonly Promise m_guiStarted = new Promise(); | |
18 |
|
18 | |||
19 | readonly IPromise m_guiFinished; |
|
19 | readonly IPromise m_guiFinished; | |
20 | // readonly IPromise m_workerFinished = new Promise<object>(); |
|
20 | // readonly IPromise m_workerFinished = new Promise<object>(); | |
@@ -30,8 +30,8 namespace Implab.Diagnostics.Interactive | |||||
30 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); |
|
30 | readonly ManualResetEvent m_pauseEvent = new ManualResetEvent(true); | |
31 |
|
31 | |||
32 | public InteractiveListener(bool global) : base(global) { |
|
32 | public InteractiveListener(bool global) : base(global) { | |
33 |
m_guiFinished = AsyncPool. |
|
33 | m_guiFinished = AsyncPool.RunThread(GuiThread); | |
34 |
/*m_workerFinished = */AsyncPool. |
|
34 | /*m_workerFinished = */AsyncPool.RunThread(QueueThread); | |
35 |
|
35 | |||
36 | m_guiStarted.Join(); |
|
36 | m_guiStarted.Join(); | |
37 | } |
|
37 | } |
@@ -39,12 +39,14 namespace Implab { | |||||
39 | } |
|
39 | } | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 |
protected |
|
42 | protected bool BeginSetResult() { | |
43 | if (!BeginTransit()) { |
|
43 | if (!BeginTransit()) { | |
44 | WaitTransition(); |
|
44 | WaitTransition(); | |
45 | if (m_state != CANCELLED_STATE) |
|
45 | if (m_state != CANCELLED_STATE) | |
46 | throw new InvalidOperationException("The promise is already resolved"); |
|
46 | throw new InvalidOperationException("The promise is already resolved"); | |
|
47 | return false; | |||
47 | } |
|
48 | } | |
|
49 | return true; | |||
48 | } |
|
50 | } | |
49 |
|
51 | |||
50 | protected void EndSetResult() { |
|
52 | protected void EndSetResult() { |
@@ -187,6 +187,8 namespace Implab.Parallels { | |||||
187 | public void EnqueueRange(T[] data, int offset, int length) { |
|
187 | public void EnqueueRange(T[] data, int offset, int length) { | |
188 | if (data == null) |
|
188 | if (data == null) | |
189 | throw new ArgumentNullException("data"); |
|
189 | throw new ArgumentNullException("data"); | |
|
190 | if (length == 0) | |||
|
191 | return; | |||
190 | if (offset < 0) |
|
192 | if (offset < 0) | |
191 | throw new ArgumentOutOfRangeException("offset"); |
|
193 | throw new ArgumentOutOfRangeException("offset"); | |
192 | if (length < 1 || offset + length > data.Length) |
|
194 | if (length < 1 || offset + length > data.Length) |
@@ -17,6 +17,7 namespace Implab.Parallels { | |||||
17 | return false; |
|
17 | return false; | |
18 | m_exclusive = true; |
|
18 | m_exclusive = true; | |
19 | m_locks = 1; |
|
19 | m_locks = 1; | |
|
20 | return true; | |||
20 | } |
|
21 | } | |
21 | } |
|
22 | } | |
22 |
|
23 | |||
@@ -31,7 +32,7 namespace Implab.Parallels { | |||||
31 | return true; |
|
32 | return true; | |
32 | } |
|
33 | } | |
33 |
|
34 | |||
34 | if (m_lock == 0) { |
|
35 | if (m_locks == 0) { | |
35 | m_exclusive = false; |
|
36 | m_exclusive = false; | |
36 | m_locks = 1; |
|
37 | m_locks = 1; | |
37 | return true; |
|
38 | return true; |
@@ -302,10 +302,11 namespace Implab { | |||||
302 | T m_result; |
|
302 | T m_result; | |
303 |
|
303 | |||
304 | public virtual void Resolve(T value) { |
|
304 | public virtual void Resolve(T value) { | |
305 |
BeginSetResult() |
|
305 | if (BeginSetResult()) { | |
306 | m_result = value; |
|
306 | m_result = value; | |
307 | EndSetResult(); |
|
307 | EndSetResult(); | |
308 | } |
|
308 | } | |
|
309 | } | |||
309 |
|
310 | |||
310 | public void Reject(Exception error) { |
|
311 | public void Reject(Exception error) { | |
311 | SetError(error); |
|
312 | SetError(error); |
General Comments 0
You need to be logged in to leave comments.
Login now