Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public NamedMutex(SharedMemoryProcessDataHeader<NamedMutexProcessDataBase> proce
_processDataHeader = processDataHeader;
}

public int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize, ref LockHolder lockHolder)
public int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, ref LockHolder lockHolder)
{
lockHolder.Dispose();
LockHolder scope = SharedMemoryManager<NamedMutexProcessDataBase>.Instance.AcquireCreationDeletionProcessLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ internal static partial class WaitSubsystem
public interface IWaitableObject
{
void OnDeleteHandle();
int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize, ref LockHolder lockHolder);
int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, ref LockHolder lockHolder);
void Signal(int count, ref LockHolder lockHolder);
}

public static int Wait(this IWaitableObject waitable, ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize)
public static int Wait(this IWaitableObject waitable, ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible)
{
Debug.Assert(waitInfo.Thread == Thread.CurrentThread);

Expand All @@ -32,7 +32,7 @@ public static int Wait(this IWaitableObject waitable, ThreadWaitInfo waitInfo, i
throw new ThreadInterruptedException();
}

return waitable.Wait_Locked(waitInfo, timeoutMilliseconds, interruptible, prioritize, ref lockHolder);
return waitable.Wait_Locked(waitInfo, timeoutMilliseconds, interruptible, ref lockHolder);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private bool IsWaiting
}

/// <summary>
/// Callers must ensure to clear the array after use. Once <see cref="RegisterWait(int, bool, bool)"/> is called (followed
/// Callers must ensure to clear the array after use. Once <see cref="RegisterWait(int, bool)"/> is called (followed
/// by a call to <see cref="Wait(int, bool, bool, ref LockHolder)"/>, the array will be cleared automatically.
/// </summary>
public WaitableObject?[] GetWaitedObjectArray(int requiredCapacity)
Expand Down Expand Up @@ -174,7 +174,7 @@ private WaitedListNode[] GetWaitedListNodeArray(int requiredCapacity)
/// <summary>
/// The caller is expected to populate <see cref="GetWaitedObjectArray"/> and pass in the number of objects filled
/// </summary>
public void RegisterWait(int waitedCount, bool prioritize, bool isWaitForAll)
public void RegisterWait(int waitedCount, bool isWaitForAll)
{
s_lock.VerifyIsLocked();
Debug.Assert(_thread == Thread.CurrentThread);
Expand Down Expand Up @@ -218,19 +218,9 @@ public void RegisterWait(int waitedCount, bool prioritize, bool isWaitForAll)

_isWaitForAll = isWaitForAll;
_waitedCount = waitedCount;
if (prioritize)
{
for (int i = 0; i < waitedCount; ++i)
{
waitedListNodes[i].RegisterPrioritizedWait(waitedObjects[i]!);
}
}
else
for (int i = 0; i < waitedCount; ++i)
{
for (int i = 0; i < waitedCount; ++i)
{
waitedListNodes[i].RegisterWait(waitedObjects[i]!);
}
waitedListNodes[i].RegisterWait(waitedObjects[i]!);
}
}

Expand Down Expand Up @@ -712,29 +702,6 @@ public void RegisterWait(WaitableObject waitableObject)
waitableObject.WaitersTail = this;
}

public void RegisterPrioritizedWait(WaitableObject waitableObject)
{
s_lock.VerifyIsLocked();
Debug.Assert(_waitInfo.Thread == Thread.CurrentThread);

Debug.Assert(waitableObject != null);

Debug.Assert(_previous == null);
Debug.Assert(_next == null);

WaitedListNode? head = waitableObject.WaitersHead;
if (head != null)
{
_next = head;
head._previous = this;
}
else
{
waitableObject.WaitersTail = this;
}
waitableObject.WaitersHead = this;
}

public void UnregisterWait(WaitableObject waitableObject)
{
s_lock.VerifyIsLocked();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static SafeWaitHandle NewMutex(bool initiallyOwned)
// by the thread. See <see cref="ThreadWaitInfo.LockedMutexesHead"/>. So, acquire the lock only after all
// possibilities for exceptions have been exhausted.
ThreadWaitInfo waitInfo = Thread.CurrentThread.WaitInfo;
bool acquiredLock = waitableObject.Wait(waitInfo, timeoutMilliseconds: 0, interruptible: false, prioritize: false) == 0;
bool acquiredLock = waitableObject.Wait(waitInfo, timeoutMilliseconds: 0, interruptible: false) == 0;
Debug.Assert(acquiredLock);
return safeWaitHandle;
}
Expand Down Expand Up @@ -242,7 +242,7 @@ public static OpenExistingResult OpenNamedMutex(string name, bool isUserScope, o
// by the thread. See <see cref="ThreadWaitInfo.LockedMutexesHead"/>. So, acquire the lock only after all
// possibilities for exceptions have been exhausted.
ThreadWaitInfo waitInfo = Thread.CurrentThread.WaitInfo;
int status = waitableObject.Wait_Locked(waitInfo, timeoutMilliseconds: 0, interruptible: false, prioritize: false, ref lockHolder);
int status = waitableObject.Wait_Locked(waitInfo, timeoutMilliseconds: 0, interruptible: false, ref lockHolder);
Debug.Assert(status == 0);
return safeWaitHandle;
}
Expand Down Expand Up @@ -361,13 +361,12 @@ public static int Wait(IntPtr handle, int timeoutMilliseconds, bool interruptibl
public static int Wait(
IWaitableObject waitableObject,
int timeoutMilliseconds,
bool interruptible = true,
bool prioritize = false)
bool interruptible = true)
{
Debug.Assert(waitableObject != null);
Debug.Assert(timeoutMilliseconds >= -1);

return waitableObject.Wait(Thread.CurrentThread.WaitInfo, timeoutMilliseconds, interruptible, prioritize);
return waitableObject.Wait(Thread.CurrentThread.WaitInfo, timeoutMilliseconds, interruptible);
}

public static int Wait(
Expand All @@ -385,7 +384,7 @@ public static int Wait(
if (waitHandles.Length == 1 && HandleManager.FromHandle(waitHandles[0]) is NamedMutex namedMutex)
{
// Named mutexes don't participate in the wait subsystem fully.
return namedMutex.Wait(waitInfo, timeoutMilliseconds, interruptible: true, prioritize: false);
return namedMutex.Wait(waitInfo, timeoutMilliseconds, interruptible: true);
}
#endif

Expand Down Expand Up @@ -439,7 +438,7 @@ public static int Wait(
WaitableObject waitableObject = waitableObjects[0]!;
waitableObjects[0] = null;
return
waitableObject.Wait(waitInfo, timeoutMilliseconds, interruptible: true, prioritize: false);
waitableObject.Wait(waitInfo, timeoutMilliseconds, interruptible: true);
}

return
Expand All @@ -449,8 +448,7 @@ public static int Wait(
waitForAll,
waitInfo,
timeoutMilliseconds,
interruptible: true,
prioritize: false);
interruptible: true);
}

public static int SignalAndWait(
Expand All @@ -471,8 +469,7 @@ public static int SignalAndWait(
IWaitableObject waitableObjectToSignal,
IWaitableObject waitableObjectToWaitOn,
int timeoutMilliseconds,
bool interruptible = true,
bool prioritize = false)
bool interruptible = true)
{
Debug.Assert(waitableObjectToSignal != null);
Debug.Assert(waitableObjectToWaitOn != null);
Expand All @@ -498,7 +495,7 @@ public static int SignalAndWait(
s_lock.VerifyIsNotLocked();
throw new InvalidOperationException(SR.Threading_WaitHandleTooManyPosts, ex);
}
return waitableObjectToWaitOn.Wait_Locked(waitInfo, timeoutMilliseconds, interruptible, prioritize, ref lockHolder);
return waitableObjectToWaitOn.Wait_Locked(waitInfo, timeoutMilliseconds, interruptible, ref lockHolder);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ private void AcceptSignal(ThreadWaitInfo waitInfo)
/// This function does not check for a pending thread interrupt. Callers are expected to do that soon after
/// acquiring <see cref="s_lock"/>.
/// </summary>
public int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, bool prioritize, ref LockHolder lockHolder)
public int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool interruptible, ref LockHolder lockHolder)
{
s_lock.VerifyIsLocked();
Debug.Assert(waitInfo != null);
Expand Down Expand Up @@ -339,7 +339,7 @@ public int Wait_Locked(ThreadWaitInfo waitInfo, int timeoutMilliseconds, bool in

WaitableObject?[] waitableObjects = waitInfo.GetWaitedObjectArray(1);
waitableObjects[0] = this;
waitInfo.RegisterWait(1, prioritize, isWaitForAll: false);
waitInfo.RegisterWait(1, isWaitForAll: false);

return
waitInfo.Wait(
Expand All @@ -355,8 +355,7 @@ public static int Wait(
bool waitForAll,
ThreadWaitInfo waitInfo,
int timeoutMilliseconds,
bool interruptible,
bool prioritize)
bool interruptible)
{
s_lock.VerifyIsNotLocked();
Debug.Assert(waitInfo != null);
Expand Down Expand Up @@ -481,7 +480,7 @@ public static int Wait(

waitableObjects = null; // no need to clear this anymore, RegisterWait / Wait will take over from here

waitInfo.RegisterWait(count, prioritize, waitForAll);
waitInfo.RegisterWait(count, waitForAll);
return waitInfo.Wait(timeoutMilliseconds, interruptible, isSleep: false, ref lockHolder);
}
finally
Expand Down
Loading