gianm commented on PR #20074: URL: https://github.com/apache/druid/pull/20074#issuecomment-5608595746
> I wonder what is the purpose of firing callbacks on close. When is this going to be necessary if `AsyncResource` are being used properly? Only the owner should close, and also only the owner should register callbacks, so why does the owner need the callbacks to fire to notify itself that it has closed its own resource? It seems like something has gone wrong with ownership if this is necessary. Thinking about this some more, I think there's a scenario where this is useful. Let's say you're a consumer and you own an `AsyncResource`, and you've registered an `addReadyCallback` that resolves a `SettableFuture` that represents the result of a computation on that resource (such as the result of a query). Let's say you decide you need to cancel yourself (maybe the query was canceled). With firing callbacks on close, you could simply call `close()` on the `AsyncResource`, and that would call the callbacks you registered to fire, which would resolve the `SettableFuture` somehow, meaning you wouldn't need to do that in addition to closing the resource. Seems useful. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
