Register
handmade.network»Forums»Hot reloading Code and Callbacks
1 posts
Hot reloading Code and Callbacks
6 months, 4 weeks ago Edited by auuhja on May 3, 2020, 8:17 a.m. Reason: Initial post
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.
Mārtiņš Možeiko
2153 posts / 1 project
Hot reloading Code and Callbacks
6 months, 4 weeks ago Edited by Mārtiņš Možeiko on May 3, 2020, 10:34 a.m.
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