In my project one function needs to call another after a certain delay. One problem is that it’s possible I’ll need to call the first function multiple times even before the first timer executes so if I had only one FTimerHandle, it would be overwritten every time I call the function. Is using a throwaway FTimerHandle safe? Is it possible that it won’t get deleted after the timer execution that would result in a memory leak? Is there a better solution for handling this situation?
Minimal example what I want to make
void MainFunction()
{
for(int i = 1; i < 10; i++)
{
Foo(i);
}
}
void Foo(float Duration)
{
FTimerHandle _;
GetWorld()->GetTimerManager().SetTimer(_, this, &AThisActor::Bar, Duration, false);
}
void Bar()
{
Do smth;
}