mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-28 15:01:07 +03:00
CHG: passive wait on DequeueWorkItem
(cherry picked from commit ac49cc8dce0519e29f26cacc5e785134300c6639)
This commit is contained in:
committed by
Piotr Wysocki
parent
ea804bada0
commit
4b16bf08ce
@@ -177,14 +177,8 @@ namespace Amib.Threading.Internal
|
|||||||
|
|
||||||
WaiterEntry waiterEntry;
|
WaiterEntry waiterEntry;
|
||||||
WorkItem workItem = null;
|
WorkItem workItem = null;
|
||||||
|
lock (this)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
while (!Monitor.TryEnter(this)) { }
|
|
||||||
//Stopwatch stopwatch = Stopwatch.StartNew();
|
|
||||||
//Monitor.Enter(this);
|
|
||||||
//stopwatch.Stop();
|
|
||||||
|
|
||||||
ValidateNotDisposed();
|
ValidateNotDisposed();
|
||||||
|
|
||||||
// If there are waiting work items then take one and return.
|
// If there are waiting work items then take one and return.
|
||||||
@@ -202,10 +196,6 @@ namespace Amib.Threading.Internal
|
|||||||
// Put the waiter with the other waiters
|
// Put the waiter with the other waiters
|
||||||
PushWaiter(waiterEntry);
|
PushWaiter(waiterEntry);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
Monitor.Exit(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare array of wait handle for the WaitHandle.WaitAny()
|
// Prepare array of wait handle for the WaitHandle.WaitAny()
|
||||||
WaitHandle [] waitHandles = new WaitHandle[] {
|
WaitHandle [] waitHandles = new WaitHandle[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user