Class SharedResourceHolder

java.lang.Object
io.grpc.internal.SharedResourceHolder

@ThreadSafe public final class SharedResourceHolder extends Object
A holder for shared resource singletons.

Components like client channels and servers need certain resources, e.g. a thread pool, to run. If the user has not provided such resources, these components will use a default one, which is shared as a static resource. This class holds these default resources and manages their life-cycles.

A resource is identified by the reference of a SharedResourceHolder.Resource object, which is typically a singleton, provided to the get() and release() methods. Each Resource object (not its class) maps to an object cached in the holder.

Resources are ref-counted and shut down after a delay when the ref-count reaches zero.