mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-18 06:27:01 +00:00
ref[event]: rename
This commit is contained in:
@@ -114,7 +114,7 @@ public abstract class EventBus {
|
||||
for (var receiver : receivers) {
|
||||
switch (receiver.bus()) {
|
||||
case CurrentThread -> doReceiver(receiver, event);
|
||||
case AsyncThread -> execute(event.executorHash(), () -> doReceiver(receiver, event));
|
||||
case AsyncThread -> asyncExecute(event.executorHash(), () -> doReceiver(receiver, event));
|
||||
// case VirtualThread -> Thread.ofVirtual().name("virtual-on" + clazz.getSimpleName()).start(() -> doReceiver(receiver, event));
|
||||
}
|
||||
}
|
||||
@@ -132,13 +132,13 @@ public abstract class EventBus {
|
||||
}
|
||||
|
||||
public static void asyncExecute(Runnable runnable) {
|
||||
execute(RandomUtils.randomInt(), runnable);
|
||||
asyncExecute(RandomUtils.randomInt(), runnable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the event thread specified by the hashcode to execute the task
|
||||
*/
|
||||
public static void execute(int executorHash, Runnable runnable) {
|
||||
public static void asyncExecute(int executorHash, Runnable runnable) {
|
||||
executors[Math.abs(executorHash % EXECUTORS_SIZE)].execute(ThreadUtils.safeRunnable(runnable));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SignalBridgeTest {
|
||||
|
||||
var countDownLatch = new CountDownLatch(executorSize);
|
||||
for (var i = 0; i < executorSize; i++) {
|
||||
EventBus.execute(i, new Runnable() {
|
||||
EventBus.asyncExecute(i, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addAndRemoveArray();
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class EntityCache<PK extends Comparable<PK>, E extends IEntity<PK>> imple
|
||||
var entity = pnode.getEntity();
|
||||
@SuppressWarnings("unchecked")
|
||||
var entityClass = (Class<E>) entityDef.getClazz();
|
||||
EventBus.execute(entityClass.hashCode(), new Runnable() {
|
||||
EventBus.asyncExecute(entityClass.hashCode(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
var collection = OrmContext.getOrmManager().getCollection(entityClass);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CronOrmPersister extends AbstractOrmPersister {
|
||||
if (!OrmContext.isStop()) {
|
||||
SchedulerBus.schedule(() -> {
|
||||
if (!OrmContext.isStop()) {
|
||||
EventBus.execute(entityDef.getClazz().hashCode(), () -> {
|
||||
EventBus.asyncExecute(entityDef.getClazz().hashCode(), () -> {
|
||||
entityCaches.persistAll();
|
||||
schedulePersist();
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TimeOrmPersister extends AbstractOrmPersister {
|
||||
public void start() {
|
||||
SchedulerBus.scheduleAtFixedRate(() -> {
|
||||
if (!OrmContext.isStop()) {
|
||||
EventBus.execute(entityDef.getClazz().hashCode(), () -> entityCaches.persistAll());
|
||||
EventBus.asyncExecute(entityDef.getClazz().hashCode(), () -> entityCaches.persistAll());
|
||||
}
|
||||
}, rate, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user