Lifecycle observer
Summary: Adds `AsyncTransport::LifecycleCallback`, an observer that is notified when a transport is closed and destroyed. Currently only supported for `AsyncSocket` and derived types (e.g., `AsyncSSLSocket`). `AsyncSocket::LifecycleCallback` is derived from `AsyncTransport::LifecycleCallback` and adds support for additional lifecycle events relevant to `AsyncSocket`. Details: - Can be used by instrumentation that ties its lifetime to that of the transport. - Intentionally separate from all existing callbacks that may be added / used by application logic because it is designed to be used by instrumentation that is generic, and thus separate / unaware of application logic. - Multiple observer can be registered, but a `folly::small_vector` is used to minimize alloc overhead in the common case of 0 - 2 being registered. - The observer implementation is responsible for calling `removeLifecycleObserver` to remove itself if it is destroyed before the socket is destroyed. Differential Revision: D21613750 fbshipit-source-id: 92bb5de30bc8bab56fa29e62800bf58e47486f1e
Showing
This diff is collapsed.
Please register or sign in to comment