mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-19 16:15:07 +00:00
The feature::when_enabled function takes a callback and returns a listener_registration object. Unless the feature were enabled right from the start, the listener_registration will be non-null and will keep the callback registered until the registration is destroyed. If the registration is destroyed before the feature is enabled, the callback will not be called. It's easy to make a mistake and forget to keep the returned registration alive - especially when, in tests, the feature is enabled early in boot, because in that case when_enabled calls the callback immediately and returns a null object instead. In order to prevent issues with prematurely dropped listener_registration in the future, mark feature::when_enabled with the [[nodiscard]] attribute.