Package io.grpc
Class ThreadLocalContextStorage
- java.lang.Object
-
- io.grpc.Context.Storage
-
- io.grpc.ThreadLocalContextStorage
-
final class ThreadLocalContextStorage extends Context.Storage
AThreadLocal-based context storage implementation. Used by default.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.ThreadLocal<Context>localContextCurrently bound context.private static java.util.logging.Loggerlog
-
Constructor Summary
Constructors Constructor Description ThreadLocalContextStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Contextcurrent()ImplementsContext.current().voiddetach(Context toDetach, Context toRestore)ImplementsContext.detach(io.grpc.Context).ContextdoAttach(Context toAttach)ImplementsContext.attach().
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
localContext
static final java.lang.ThreadLocal<Context> localContext
Currently bound context.
-
-
Method Detail
-
doAttach
public Context doAttach(Context toAttach)
Description copied from class:Context.StorageImplementsContext.attach().Caution:
Context.attach()interprets a return value ofnullto mean the same thing asContext.ROOT.See also:
Context.Storage.current().- Specified by:
doAttachin classContext.Storage- Parameters:
toAttach- the context to be attached- Returns:
- A
Contextthat should be passed back intoContext.Storage.detach(Context, Context)as thetoRestoreparameter.nullis a valid return value, but see caution note.
-
detach
public void detach(Context toDetach, Context toRestore)
Description copied from class:Context.StorageImplementsContext.detach(io.grpc.Context).- Specified by:
detachin classContext.Storage- Parameters:
toDetach- the context to be detached. Should be, or be equivalent to, the current context of the current scopetoRestore- the context to be the current. Should be, or be equivalent to, the context of the outer scope
-
current
public Context current()
Description copied from class:Context.StorageImplementsContext.current().Caution:
Contextinterprets a return value ofnullto mean the same thing asContext.ROOT.See also
Context.Storage.doAttach(Context).- Specified by:
currentin classContext.Storage- Returns:
- The context of the current scope.
nullis a valid return value, but see caution note.
-
-