Open
Description
Description
CompositeChangeToken.ActiveChangeCallbacks returns true if at least one of the inner change tokens has active callbacks. It seems to me that it should return true only if all inner change tokens have active callbacks.
Rationale
IChangeToken.ActiveChangeCallbacks indicates whether the consumer can rely on its callback being invoked, or must instead poll the IChangeToken.HasChanged property.
- If some of the inner change tokens of CompositeChangeToken have active callbacks but others don't, then the current implementation of CompositeChangeToken.ActiveChangeCallbacks returns true, and the consumer may rely on the callback. However, it would be safer to poll in this situation, as some of the inner change tokens may detect a change but not invoke the callback. That is, CompositeChangeToken.ActiveChangeCallbacks should return false.
- If there are no inner change tokens, then CompositeChangeToken.ActiveChangeCallbacks returns false, directing the consumer to poll the IChangeToken.HasChanged property. However, HasChanged will constantly return false because no change can ever be detected. It might be more efficient not to poll in this situation. That is, CompositeChangeToken.ActiveChangeCallbacks should perhaps return true. I have not benchmarked this.
Configuration
Microsoft.Extensions.Primitives 2.1.6, but 5.0.0-preview.7.20364.11 behaves the same:
Regression?
No, it has always been like this.
Other information
- aspnet/FileSystem@15c9f1d#diff-c4244fff2896e0080f8eeaa5c8c7c2bcR51-R54 added CompositeFileChangeToken and it already worked like this.
- Add CompositeChangeToken to Primitives extensions#175 added CompositeChangeToken.