mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-12 22:15:02 +00:00
perf[orm]: entity cache使用相同的线程去更新
This commit is contained in:
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();
|
||||
|
||||
Reference in new issue
Block a user