From 4282d15a5e69a6b4c822c87d27a1ed6e7e618f00 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期三, 02 七月 2025 13:29:12 +0800
Subject: [PATCH] 初始化1.0
---
src/main/java/com/zy/core/cache/MessageQueue.java | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/core/cache/MessageQueue.java b/src/main/java/com/zy/core/cache/MessageQueue.java
index cf6e475..301dd52 100644
--- a/src/main/java/com/zy/core/cache/MessageQueue.java
+++ b/src/main/java/com/zy/core/cache/MessageQueue.java
@@ -1,6 +1,5 @@
package com.zy.core.cache;
-import com.zy.asrs.utils.CommandUtils;
import com.zy.core.Slave;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
@@ -62,7 +61,6 @@
* 濡傛灉鍙戠幇闃熷垪宸叉弧鏃犳硶娣诲姞鐨勮瘽锛屼細鐩存帴杩斿洖false銆�
*/
public static boolean offer(SlaveType type, Integer id, Task task) {
- CommandUtils.offer(type, id, task);
switch (type) {
case Crn:
return CRN_EXCHANGE.get(id).offer(task);
@@ -126,10 +124,10 @@
}
}
- public static void clear(SlaveType type, Integer id){
+ public static void clear(SlaveType type, Integer id) {
switch (type) {
case Crn:
-
+
CRN_EXCHANGE.get(id).clear();
break;
case Devp:
@@ -151,5 +149,20 @@
break;
}
}
+ public static boolean offer(SlaveType type, Integer devpId, Task task, Runnable callback) {
+ boolean result = offer(type, devpId, task); // 鍏堟墽琛屽師鏈変换鍔¢�昏緫
+ if (result && callback != null) {
+ new Thread(() -> {
+ try {
+ Thread.sleep(200); // 妯℃嫙浠诲姟鎵ц鏃堕棿
+ callback.run();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }).start();
+ }
+ return result;
+ }
+
}
--
Gitblit v1.9.1