Closed vincentbernat closed 8 years ago
Since nextGoCallbackId
is always incrementing by one, if/when an overflow happens wouldn't the map be "filled" at that point resulting in an infinite loop?
Nope. The typical use case is that you have events setup since the application was started (for example, they get the goCallbackId 2) and you have events that are created and teared down during the lifetime of the application. So, you have a lot of free ID. But once you overflow, you will reuse 2 which was not free. 3 is free.
When registering/deregistering a lot of callbacks, in a long-running process, it may be possible for
nextGoCallbackId
to overflow. Therefore, after incrementing it, check that its number is not already used. This should be a rare event as the map should stay quite sparse.