[*] Release AuAsyncTimer callback references as soon as the object is canceled
This commit is contained in:
parent
d520b0ce42
commit
85cf0a793a
@ -28,7 +28,9 @@ namespace Aurora::Async
|
||||
|
||||
void AsyncFuncTimer::CancelTimer()
|
||||
{
|
||||
AU_LOCK_GUARD(this->mutex);
|
||||
this->Cancel();
|
||||
AuResetMember(this->pCallback);
|
||||
}
|
||||
|
||||
AuUInt64 AsyncFuncTimer::GetLastTime()
|
||||
@ -53,6 +55,7 @@ namespace Aurora::Async
|
||||
|
||||
void AsyncFuncTimer::DispatchTask(IWorkItemHandler::ProcessInfo &info)
|
||||
{
|
||||
AU_LOCK_GUARD(this->mutex);
|
||||
info.type = ETickType::eRerun;
|
||||
|
||||
auto uTickCount = ++this->uTickCount;
|
||||
@ -68,13 +71,26 @@ namespace Aurora::Async
|
||||
|
||||
info.reschedSteadyClockAbsNs = this->uNextTickTime;
|
||||
|
||||
if (this->pCallback->OnTick(uTickCount, uDelta, this->uLastTickTime))
|
||||
if (!this->pCallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (this->pCallback->OnTick(uTickCount, uDelta, this->uLastTickTime))
|
||||
{
|
||||
info.type = ETickType::eSchedule;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.type = ETickType::eFinished;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
info.type = ETickType::eSchedule;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.type = ETickType::eFinished;
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,5 +37,6 @@ namespace Aurora::Async
|
||||
AuUInt64 uInterval {};
|
||||
AuUInt64 uTickCount {};
|
||||
bool bCatchUp { false };
|
||||
AuCriticalSection mutex;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user