graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.21k stars 75 forks source link

Stop timer when it's no longer needed #109

Closed justinmayhew closed 2 months ago

justinmayhew commented 11 months ago

When a batch is triggered by hitting the batch capacity, the timer is no longer needed and the resources associated with it can be released.

rwrz commented 2 months ago

It was important before Go 1.23, now it is not anymore [ref]:

Before Go 1.23, this documentation warned that the underlying Timer would not be recovered by the garbage collector until the timer fired, and that if efficiency was a concern, code should use NewTimer instead and call Timer.Stop if the timer is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced, unstopped timers. There is no reason to prefer NewTimer when After will do.

justinmayhew commented 2 months ago

Closing as no longer needed.