Hot reloading Code and Callbacks

Hi everyone,

I implemented Casey's DLL-hot reloading system and it works great.
However, I am not sure how to handle callback functions properly. For example, say we have a job, which goes on over multiple frames, like asynchronously loading an asset. I would like to get notified when the job is done, so callback functions seem like a good idea. When the DLL gets reloaded in the meantime though, the function pointer gets invalidated.
Am I missing an obvious alternative to callback functions?

As far as I understand in Handmade Hero, jobs are never spanning multiple frames, so callback functions only need to stay valid for one frame. Since the DLL gets reloaded on frame boundaries, there is no problem.

Can someone help me out here? Any help is appreciated.

Edited by auuhja on Reason: Initial post
In Handmade Hero jobs can spawn multiple frames. The asset loading job can finish who knows when - many frames later.
But when code detects it needs to do reload, it flushes all jobs - it will wait until all jobs finish executing, and only then does reload.

This flushing was implemented in day 143: https://hero.handmade.network/episode/code/day143/#2695

Edited by Mārtiņš Možeiko on