Skip to content

Commit b1f2b63

Browse files
committed
Use semaphore instead of MRE in FutureList
1 parent 5f55454 commit b1f2b63

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

VS-QuickNavigation/Utils/Future.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public bool IsCompleted
5656
public class FutureList<T> : IEnumerable<Future<T>>
5757
{
5858
List<Future<T>> m_lFutures;
59-
ManualResetEvent m_oMre;
59+
Semaphore m_oSemaphore;
6060

6161
public FutureList()
6262
{
6363
m_lFutures = new List<Future<T>>();
64-
m_oMre = new ManualResetEvent(false);
64+
m_oSemaphore = new Semaphore(0, int.MaxValue);
6565
}
6666

6767
public void Add(Future<T> oResult)
@@ -70,13 +70,12 @@ public void Add(Future<T> oResult)
7070
{
7171
oResult.Callback = OnFutureCallback;
7272
m_lFutures.Add(oResult);
73-
//oResult.MRE = m_oMre;
7473
}
7574
}
7675

7776
void OnFutureCallback(Future<T> oResult)
7877
{
79-
m_oMre.Set();
78+
m_oSemaphore.Release();
8079
}
8180

8281
public List<Future<T>> GetList()
@@ -86,8 +85,7 @@ public List<Future<T>> GetList()
8685

8786
public void WaitAny()
8887
{
89-
m_oMre.WaitOne();
90-
m_oMre.Reset();
88+
m_oSemaphore.WaitOne();
9189
}
9290

9391
public void WaitAll()

0 commit comments

Comments
 (0)