[*] Minor NT LoopQueue fixes/improvements
This commit is contained in:
parent
de25694416
commit
85102ec7ce
@ -653,13 +653,14 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
if (this->bIsWinLoop_)
|
||||
{
|
||||
status = ::MsgWaitForMultipleObjectsEx(next, this->handleArrayAnd_.data() + index, timeDelta, QS_ALLPOSTMESSAGE | QS_ALLINPUT | QS_ALLEVENTS, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE | MWMO_WAITALL);
|
||||
status = ::MsgWaitForMultipleObjectsEx(next, this->handleArrayAnd_.data() + index, timeDelta, QS_ALLINPUT, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ::WaitForMultipleObjectsEx(next, this->handleArrayAnd_.data() + index, true, timeDelta, true);
|
||||
}
|
||||
} while (status == WAIT_IO_COMPLETION);
|
||||
}
|
||||
while (status == WAIT_IO_COMPLETION);
|
||||
|
||||
if (status == WAIT_OBJECT_0 + next)
|
||||
{
|
||||
@ -758,7 +759,7 @@ namespace Aurora::IO::Loop
|
||||
AuUInt32 ret {};
|
||||
bool lastItr {};
|
||||
|
||||
AuUInt64 startTime = AuTime::SteadyClockNS();
|
||||
AuUInt64 startTime = AuTime::SteadyClockMS();
|
||||
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
||||
AuUInt32 chuggerIndex {};
|
||||
bool bTriggerWin32 {};
|
||||
@ -782,7 +783,7 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
AuList<AuSPtr<ILoopSource>> trigger;
|
||||
|
||||
AuUInt64 startTime = AuTime::SteadyClockNS();
|
||||
AuUInt64 startTime = AuTime::SteadyClockMS();
|
||||
AuUInt64 endTime = timeout ? (startTime + timeout) : AuUInt64(-1);
|
||||
AuUInt32 chuggerIndex {};
|
||||
bool bTriggerWin32 {};
|
||||
@ -856,7 +857,8 @@ namespace Aurora::IO::Loop
|
||||
if (index > count) index = 0;
|
||||
bool active = this->hEvent_ == INVALID_HANDLE_VALUE;
|
||||
|
||||
while (count != index)
|
||||
|
||||
while (count != index )
|
||||
{
|
||||
auto next = AuMin(count - index, AuUInt32(MAXIMUM_WAIT_OBJECTS));
|
||||
|
||||
@ -879,7 +881,15 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
do
|
||||
{
|
||||
status = ::MsgWaitForMultipleObjectsEx(next, this->handleArrayOr_.data() + index, sleepMS, QS_ALLPOSTMESSAGE | QS_ALLINPUT | QS_ALLEVENTS, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE);
|
||||
status = ::MsgWaitForMultipleObjectsEx(next, this->handleArrayOr_.data() + index, sleepMS, QS_ALLINPUT, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE);
|
||||
|
||||
{
|
||||
auto temp2 = status;
|
||||
while (temp2 == WAIT_IO_COMPLETION)
|
||||
{
|
||||
temp2 = SleepEx(0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (status == WAIT_IO_COMPLETION);
|
||||
|
||||
@ -973,13 +983,22 @@ namespace Aurora::IO::Loop
|
||||
{
|
||||
if (this->bIsWinLoop_)
|
||||
{
|
||||
temp = ::MsgWaitForMultipleObjectsEx(this->handleArrayOr_.size(), this->handleArrayOr_.data(), sleepDelta, QS_ALLPOSTMESSAGE | QS_ALLINPUT | QS_ALLEVENTS, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE);
|
||||
temp = ::MsgWaitForMultipleObjectsEx(this->handleArrayOr_.size(), this->handleArrayOr_.data(), sleepDelta, QS_ALLINPUT, MWMO_INPUTAVAILABLE | MWMO_ALERTABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = ::WaitForMultipleObjectsEx(this->handleArrayOr_.size(), this->handleArrayOr_.data(), false, sleepDelta, true);
|
||||
}
|
||||
} while (temp == WAIT_IO_COMPLETION);
|
||||
|
||||
{
|
||||
auto temp2 = temp;
|
||||
while (temp2 == WAIT_IO_COMPLETION)
|
||||
{
|
||||
temp2 = SleepEx(0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (temp == WAIT_IO_COMPLETION);
|
||||
|
||||
status = WaitToRetStatus(temp);
|
||||
|
||||
@ -989,32 +1008,42 @@ namespace Aurora::IO::Loop
|
||||
}
|
||||
}
|
||||
|
||||
if (indexOfTriggered == this->handleArrayOr_.size())
|
||||
bool bIsPump = this->handleArrayOr_.size() == indexOfTriggered;
|
||||
|
||||
if (bIsPump)
|
||||
{
|
||||
TryPumpWin32();
|
||||
triggeredCount++;
|
||||
if (poll)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (TryPumpWin32())
|
||||
{
|
||||
triggeredCount++;
|
||||
bTriggerWin32 = true;
|
||||
}
|
||||
return triggeredCount;
|
||||
}
|
||||
else if (!status)
|
||||
{
|
||||
StartUserAndTakeOwn();
|
||||
ConsiderEvicitingTimeoutsAll();
|
||||
StartUserAndTakeOwn_Release();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TryPumpWin32())
|
||||
if (!poll &&
|
||||
TryPumpWin32())
|
||||
{
|
||||
triggeredCount++;
|
||||
bTriggerWin32 = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isPump = this->handleArrayOr_.size() == indexOfTriggered;
|
||||
|
||||
StartUserAndTakeOwn();
|
||||
|
||||
|
||||
AuUInt firstTriggered {};
|
||||
if (status)
|
||||
AuUInt firstTriggered { reinterpret_cast<AuUInt>(this->handleArrayOr_[indexOfTriggered]) };
|
||||
{
|
||||
if (!isPump)
|
||||
{
|
||||
firstTriggered = reinterpret_cast<AuUInt>(this->handleArrayOr_[indexOfTriggered]);
|
||||
}
|
||||
|
||||
{
|
||||
Iterator queueIterator(this);
|
||||
AuSInt indexOffset {};
|
||||
@ -1169,10 +1198,6 @@ namespace Aurora::IO::Loop
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsiderEvicitingTimeoutsAll();
|
||||
}
|
||||
|
||||
StartUserAndTakeOwn_Release();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user