perf[orm]: entity cache使用相同的线程去更新

This commit is contained in:
jaysunxiao committed 2021-08-05 17:43:24 +08:00
1 parent 3ef1b7a90e
commit 20dd452697
3 files changed
+6 -2

No files matched your search

@@ -91,6 +91,10 @@ public abstract class EventBus {
return executors[RandomUtils.randomInt(EXECUTORS_SIZE)];
}
public static Executor asyncExecute(int hashcode) {
return executors[Math.abs(hashcode % EXECUTORS_SIZE)];
}
private static void doSubmit(IEvent event, List<IEventReceiver> receiverList) {
for (var receiver : receiverList) {
try {
@@ -78,7 +78,7 @@ public class CronOrmPersister extends AbstractOrmPersister {
@Override
public void run() {
if (!OrmContext.isStop()) {
EventBus.asyncExecute().execute(new Runnable() {
EventBus.asyncExecute(entityDef.getClazz().hashCode()).execute(new Runnable() {
@Override
public void run() {
entityCaches.persistAll();
@@ -47,7 +47,7 @@ public class TimeOrmPersister extends AbstractOrmPersister {
@Override
public void run() {
if (!OrmContext.isStop()) {
EventBus.asyncExecute().execute(new Runnable() {
EventBus.asyncExecute(entityDef.getClazz().hashCode()).execute(new Runnable() {
@Override
public void run() {
entityCaches.persistAll();