[*] 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,6 +71,13 @@ namespace Aurora::Async
|
||||
|
||||
info.reschedSteadyClockAbsNs = this->uNextTickTime;
|
||||
|
||||
if (!this->pCallback)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (this->pCallback->OnTick(uTickCount, uDelta, this->uLastTickTime))
|
||||
{
|
||||
info.type = ETickType::eSchedule;
|
||||
@ -77,6 +87,12 @@ namespace Aurora::Async
|
||||
info.type = ETickType::eFinished;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
info.type = ETickType::eSchedule;
|
||||
SysPushErrorCatch();
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncFuncTimer::Cleanup()
|
||||
{
|
||||
|
@ -37,5 +37,6 @@ namespace Aurora::Async
|
||||
AuUInt64 uInterval {};
|
||||
AuUInt64 uTickCount {};
|
||||
bool bCatchUp { false };
|
||||
AuCriticalSection mutex;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user