-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ThreadLocal integration #130
Comments
Sometimes we need to use the thread local defined in thirdparty libraries. Support register ThreadLocal to be transmitted with TransmittableThreadLocals.
The integration transmit for
Integrate
// ThreadLocal will be transmitted after this
<T> boolean Transmitter.register(
ThreadLocal<T> threadLocal, Function<T, T> copyLambda);
// Then this ThreadLocal will not be transmitted
<T> boolean Transmitter.unregister(ThreadLocal<T> threadLocal);
集成ThreadLocal,提供一个用于拷贝的
// 接下来这个 ThreadLocal 会被传递
<T> boolean Transmitter.register(
ThreadLocal<T> threadLocal, Function<T, T> copyLambda);
// 接下来这个 ThreadLocal 不会被传递
<T> boolean Transmitter.unregister(ThreadLocal<T> threadLocal); |
Sometimes we need to use the thread local defined in thirdparty libraries. Support register ThreadLocal to be transmitted with TransmittableThreadLocals.
Sometimes we need to use the thread local defined in thirdparty libraries. Support register ThreadLocal to be transmitted with TransmittableThreadLocals.
released in v2.11.0. |
In the user code,
ThreadLocal
can be passed as a cross-thread transmit capability by defining it asTransmittableThreadLocal
. However, if the user relies on a library that uses theThreadLocal
implementation, it cannot modify its code at this time, so it cannot be easily used in asynchronous. The ability to get context transmit in the code.One possible solution is the integration transmit for
ThreadLocal
.Users can register the
ThreadLocal
that needs to be passed, and can provide two methods:ThreadLocal
集成支持用户代码中
ThreadLocal
通过定义为TransmittableThreadLocal
即可获得跨线程传递能力,但是如果用户依赖的库中使用的是ThreadLocal
实现,这个时候又无法修改其代码,就不能很方便的在异步化的代码中获得上下文传递的能力了。一个可行的解决方式是开放集成的能力。
用户可以将需要传递的
ThreadLocal
注册进来,可以提供两个方法:The text was updated successfully, but these errors were encountered: