Creating a Heartbeat-based timer: is delta time as accurate as I can get?

I officially want to get rid of standalone wait calls and move to a Heartbeat-based timer. I feel that this is more effective for my development as I won’t need to sleep the thread and I will be able to create interruptions (pauses or cancellations) for functions scheduled to run after a bit.

I assume that most standard games in the industry run any waiting functions with ms rather than full seconds. In addition, wait is inaccurate: it waits n amount of seconds plus extra for an open slot in the task scheduler, meaning it can wait longer than intended.

I’ve seen a couple of nice solutions for Heartbeat-based timers and they rely on the delta time passed each time the signal is fired. This is then added to a variable, usually elapsedTime that begins at 0 and the code waits until the elapsedTime variable surpasses the time argument requested.

Is accumulative time deltas as accurate as I can get right now, or are there more accurate methods (e.g. having the timer increment each time tick()'s number increases in the hundredths place)?

Great! I definitely recommend using a custom scheduler. I use tick for my timers because it seems the most reliable and makes it easy to connect to an arbitrary time in the future, but delta time may have better floating point precision.

I also recommend doing a binary search when disconnecting tasks if you can.