cc.redberry.core.context
Class ContextManager
- java.lang.Object
-
- cc.redberry.core.context.ContextManager
-
public final class ContextManager extends java.lang.ObjectThis class implements context management logic.It holds current thread-local context of Redberry session (see description for
Contextclass). It is possible to set context explicitly usingsetCurrentContext(Context)method. Each thread is linked to its own context. All child threads created viaExecutorServicefromgetExecutorService()have same context.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static ContextgetCurrentContext()Returns the current context of Redberry session.static java.util.concurrent.ExecutorServicegetExecutorService()Returns thread-localExecutorServicewith fixed context.static ContextinitializeNew()This method initializes and sets current session context by the default value defined inDefaultContextFactory.static ContextinitializeNew(ContextSettings contextSettings)This method initializes and sets current session context from the specifiedcontext settings(ContextSettings).static voidsetCurrentContext(Context context)Sets current thread-local context to the specified one.
-
-
-
Method Detail
-
getCurrentContext
public static Context getCurrentContext()
Returns the current context of Redberry session.- Returns:
- the current context of Redberry session.
-
initializeNew
public static Context initializeNew()
This method initializes and sets current session context by the default value defined inDefaultContextFactory. After this step, all tensors that exist in the thread will be invalidated.- Returns:
- created context
-
initializeNew
public static Context initializeNew(ContextSettings contextSettings)
This method initializes and sets current session context from the specifiedcontext settings(ContextSettings). After invocation of this method, all the tensors that exist in the current thread will be invalidated.- Returns:
- created context
-
setCurrentContext
public static void setCurrentContext(Context context)
Sets current thread-local context to the specified one. After this step, all the tensors that exist in the thread will be invalidated.- Parameters:
context- context
-
getExecutorService
public static java.util.concurrent.ExecutorService getExecutorService()
Returns thread-localExecutorServicewith fixed context. All threads linked to thisExecutorServicewill have same context.- Returns:
- thread-local
ExecutorServicewith fixed context
-
-
DataMelt 3.0 © DataMelt by jWork.ORG