Skip to content

Commit

Permalink
Start v4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lWoHvYe committed Jun 18, 2024
1 parent b885d15 commit 8b999f6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<project>

<project.core.version>4.3.0-rho</project.core.version>
<project.core.version>4.4.0-sigma</project.core.version>

<!-- system模块 -->
<dependency>
Expand All @@ -63,9 +63,9 @@
##### Gradle

```groovy
// 4.x系列将基于Java 21, 部分module使用Kotlin, 使用Gradle build
// 4.x系列基于Java 21, 部分module使用Kotlin, 使用Gradle build
ext { // 这个定义是可以传递的
unicornVersion = '4.3.0-rho'
unicornVersion = '4.4.0-sigma'
}
implementation "com.lwohvye:unicorn-security:$unicornVersion"
Expand Down Expand Up @@ -128,7 +128,8 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {

项目采用按功能分模块的开发方式,结构如下

- `unicorn-core` 系统的Core模块,BaseClass及各种Util,(基于Multi-Release JAR Files,Support Java 17 - 21)
- `unicorn-core` 系统的Core模块,BaseClass及各种Util,(基于Multi-Release JAR Files,Support Java 17 - 21),
baseline 为Java 17, 在Runtime = 17 时使用传统threadPool,在Runtime >= 21时使用Virtual Threads

- `unicorn-beans` 基础Beans的Definition及Configuration,To C业务可只引入该dependency

Expand All @@ -151,7 +152,7 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {
#### 详细结构

```
- unicorn-core 公共模块
- unicorn-core 公共模块(Baseline Java 17)
- annotation 为系统自定义注解
- base 提供了Entity、Service、DTO基类和mapstruct的通用mapper
- exception 项目自定义异常类
Expand All @@ -161,6 +162,7 @@ implementation("com.lwohvye:unicorn-security:$unicornVersion") {
- JDKUtils, UnsafeUtils
- XRabbitAbstractProducer, YRabbitAbstractConsumer
- SecurityUtils, ReactiveSecurityUtils
- java21/utils Virtual Threads for Java Runtime 21+ (Multi-Release Jar)
- unicorn-beans 基础Bean
- advice 统一数据返回及异常处理
- config 基础配置,Security配置,redis配置,openApi配置,Rsa配置等
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ plugins {
}

group = "com.lwohvye"
version = "4.4.0-sigma"
version = "4.5.0-tau-Beta"

java {
withSourcesJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,45 +83,45 @@ public static void structuredExecute(Runnable eventual, Runnable... tasks) {
/*
var i = c.incrementAndGet();
ConcurrencyUtils.threadLocal.set(String.valueOf(i));
threadPoolExecutor.execute(ConcurrencyUtils.withThreadLocalAndThreadPool(() -> {
var s = ConcurrencyUtils.threadLocal.get();
threadPoolExecutor.execute(ConcurrencyUtils.withTLTP(() -> {
var s = ConcurrencyUtils.threadLocal.get(); // 这里获得的就是Target val
log.info((String) s);
}));
threadLocal.remove();
*/

/*
var voidCompletableFuture = CompletableFuture.runAsync(ConcurrencyUtils.withThreadLocalAndThreadPool(() -> {
var voidCompletableFuture = CompletableFuture.runAsync(ConcurrencyUtils.withTLTP(() -> {
var s = ConcurrencyUtils.threadLocal.get();
log.info((String) s);
}));
var unused = voidCompletableFuture.get();
var stringCompletableFuture = CompletableFuture.supplyAsync(ConcurrencyUtils.withThreadLocalAndThreadPool(() -> {
var stringCompletableFuture = CompletableFuture.supplyAsync(ConcurrencyUtils.withTLTP(() -> {
var s = ConcurrencyUtils.threadLocal.get();
log.info((String) s);
return String.valueOf(s);
}));
var s = stringCompletableFuture.get();
*/

public static Runnable withThreadLocalAndThreadPool(Runnable runnable) {
public static Runnable withTLTP(Runnable runnable) {
var sharedVar = ConcurrencyUtils.threadLocal.get(); // 在parent thread中执行
return () -> { // sharedVar的传递还不清楚,但已知因为是非基本类型,所以传递的引用
ConcurrencyUtils.threadLocal.set(sharedVar); // 在sub thread中执行
runnable.run(); // runnable在调用 run()的线程执行,当前是 sub thread。
};
}

public static <U> Supplier<U> withThreadLocalAndThreadPool(Supplier<U> supplier) {
public static <U> Supplier<U> withTLTP(Supplier<U> supplier) {
var sharedVar = ConcurrencyUtils.threadLocal.get();
return () -> {
ConcurrencyUtils.threadLocal.set(sharedVar);
return supplier.get();
};
}

public static <V> Callable<V> withThreadLocalAndThreadPool(Callable<V> callable) {
public static <V> Callable<V> withTLTP(Callable<V> callable) {
var sharedVar = ConcurrencyUtils.threadLocal.get();
return () -> {
ConcurrencyUtils.threadLocal.set(sharedVar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@ public static void structuredExecute(Runnable eventual, Runnable... tasks) {
}

// 下面这个,就是解决InheritableThreadLocal 和 ThreadPool一起使用时的问题,使用ThreadLocal 然后自行实现值的传递
public static Runnable withThreadLocalAndThreadPool(Runnable runnable) {
public static Runnable withTLTP(Runnable runnable) {
var sharedVar = ConcurrencyUtils.threadLocal.get();
return () -> {
ConcurrencyUtils.threadLocal.set(sharedVar);
runnable.run();
};
}

public static <U> Supplier<U> withThreadLocalAndThreadPool(Supplier<U> supplier) {
public static <U> Supplier<U> withTLTP(Supplier<U> supplier) {
var sharedVar = ConcurrencyUtils.threadLocal.get();
return () -> {
ConcurrencyUtils.threadLocal.set(sharedVar);
return supplier.get();
};
}

public static <V> Callable<V> withThreadLocalAndThreadPool(Callable<V> callable) {
public static <V> Callable<V> withTLTP(Callable<V> callable) {
var sharedVar = ConcurrencyUtils.threadLocal.get();
return () -> {
ConcurrencyUtils.threadLocal.set(sharedVar);
Expand Down

0 comments on commit 8b999f6

Please sign in to comment.