[*] Update LoopQueue semantics. Pending NT port
This commit is contained in:
parent
499aaeedab
commit
2ce106d8a9
@ -23,7 +23,7 @@ namespace Aurora::Loop
|
||||
* @brief called under Wait[All/Any[Ex]] once an object is signaled
|
||||
* @return should pop from ILoopQueue
|
||||
*/
|
||||
AUI_METHOD(bool, OnFinished, (const AuSPtr<ILoopSource> &, source)),
|
||||
AUI_METHOD(bool, OnFinished, (const AuSPtr<ILoopSource> &, source, AuUInt8, position)),
|
||||
|
||||
/**
|
||||
* @brief called under Wait[All/Any[Ex]] once an object timesout before being evicted
|
||||
|
@ -53,6 +53,8 @@ namespace Aurora::IPC
|
||||
return false;
|
||||
}
|
||||
|
||||
this->word = 0;
|
||||
|
||||
this->flags[0] = in[0] == 'Y';
|
||||
this->flags[1] = in[1] == 'Y';
|
||||
this->flags[2] = in[2] == 'Y';
|
||||
|
@ -825,6 +825,7 @@ namespace Aurora::Loop
|
||||
AuPair<bool, bool> LoopQueue::SourceExtended::DoWork(int fd)
|
||||
{
|
||||
bool bShouldRemove {true};
|
||||
AuUInt8 uPosition {};
|
||||
|
||||
if (!this->bHasCommited)
|
||||
{
|
||||
@ -839,33 +840,77 @@ namespace Aurora::Loop
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &handler : this->subscribers)
|
||||
bool bOverload {};
|
||||
|
||||
if ((this->subscribers.empty()) &&
|
||||
(this->subscriberExs.empty()))
|
||||
{
|
||||
bOverload = true;
|
||||
}
|
||||
|
||||
// Notify callbacks...
|
||||
|
||||
for (auto itr = this->subscriberExs.begin();
|
||||
itr != this->subscriberExs.end(); )
|
||||
{
|
||||
bool result;
|
||||
auto handler = *itr;
|
||||
|
||||
try
|
||||
{
|
||||
bShouldRemove &= handler->OnFinished(this->source);
|
||||
result = handler->OnFinished(this->source, uPosition++);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
}
|
||||
|
||||
if (bShouldRemove)
|
||||
{
|
||||
for (const auto &handler : this->subscriberExs)
|
||||
bShouldRemove &= result;
|
||||
|
||||
if (result)
|
||||
{
|
||||
try
|
||||
{
|
||||
bShouldRemove &= handler->OnFinished(this->source);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
itr = this->subscriberExs.erase(itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto itr = this->subscribers.begin();
|
||||
itr != this->subscribers.end(); )
|
||||
{
|
||||
bool result;
|
||||
auto handler = *itr;
|
||||
|
||||
try
|
||||
{
|
||||
result = handler->OnFinished(this->source);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
|
||||
bShouldRemove &= result;
|
||||
|
||||
if (result)
|
||||
{
|
||||
itr = this->subscribers.erase(itr);
|
||||
}
|
||||
else
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
|
||||
// Evict when subs count hit zero, not when sub count started off at zero
|
||||
if (bOverload)
|
||||
{
|
||||
bShouldRemove = false;
|
||||
}
|
||||
|
||||
// Notify global subscribers, allowing them to preempt removal
|
||||
if (bShouldRemove)
|
||||
{
|
||||
AU_LOCK_GUARD(this->parent->globalLockMutex_);
|
||||
@ -881,13 +926,6 @@ namespace Aurora::Loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((this->subscribers.empty()) &&
|
||||
(this->subscriberExs.empty()))
|
||||
{
|
||||
bShouldRemove = false;
|
||||
}
|
||||
|
||||
return AuMakePair(true, bShouldRemove);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user