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>
localContext
Currently bound context.private static java.util.logging.Logger
log
-
Constructor Summary
Constructors Constructor Description ThreadLocalContextStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Context
current()
ImplementsContext.current()
.void
detach(Context toDetach, Context toRestore)
ImplementsContext.detach(io.grpc.Context)
.Context
doAttach(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.Storage
ImplementsContext.attach()
.Caution:
Context.attach()
interprets a return value ofnull
to mean the same thing asContext.ROOT
.See also:
Context.Storage.current()
.- Specified by:
doAttach
in classContext.Storage
- Parameters:
toAttach
- the context to be attached- Returns:
- A
Context
that should be passed back intoContext.Storage.detach(Context, Context)
as thetoRestore
parameter.null
is a valid return value, but see caution note.
-
detach
public void detach(Context toDetach, Context toRestore)
Description copied from class:Context.Storage
ImplementsContext.detach(io.grpc.Context)
.- Specified by:
detach
in 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.Storage
ImplementsContext.current()
.Caution:
Context
interprets a return value ofnull
to mean the same thing asContext.ROOT
.See also
Context.Storage.doAttach(Context)
.- Specified by:
current
in classContext.Storage
- Returns:
- The context of the current scope.
null
is a valid return value, but see caution note.
-
-