ref[event]: rename IEvent threadId method name to executorHash

This commit is contained in:
godotg
2023-03-08 12:00:04 +08:00
parent a4e28e1014
commit da9cb5f608
2 changed files with 4 additions and 4 deletions
@@ -118,7 +118,7 @@ public abstract class EventBus {
var listAsync = receiverMapAsync.get(clazz);
if (CollectionUtils.isNotEmpty(listAsync)) {
for (var receiver : listAsync) {
executors[Math.abs(event.threadId() % EXECUTORS_SIZE)].execute(() -> {
execute(event.executorHash(), () -> {
try {
receiver.invoke(event);
} catch (Exception e) {
@@ -139,8 +139,8 @@ public abstract class EventBus {
/**
* Use the event thread specified by the hashcode to execute the task
*/
public static void execute(int hashcode, Runnable runnable) {
executors[Math.abs(hashcode % EXECUTORS_SIZE)].execute(SafeRunnable.valueOf(runnable));
public static void execute(int executorHash, Runnable runnable) {
executors[Math.abs(executorHash % EXECUTORS_SIZE)].execute(SafeRunnable.valueOf(runnable));
}
/**
@@ -37,7 +37,7 @@ public interface IEvent {
*
* @return 线程池的执行的一个参数
*/
default int threadId() {
default int executorHash() {
return RandomUtils.randomInt();
}