File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
hsweb-core/src/main/java/org/hswebframework/web/event Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ public interface AsyncEvent {
21
21
*/
22
22
void async (Publisher <?> publisher );
23
23
24
+ /**
25
+ * 注册一个优先级高的任务
26
+ * @param publisher 任务
27
+ */
28
+ void first (Publisher <?> publisher );
29
+
24
30
/**
25
31
* 推送事件到 ApplicationEventPublisher
26
32
*
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ public class DefaultAsyncEvent implements AsyncEvent {
9
9
10
10
@ Getter
11
11
private Mono <Void > async = Mono .empty ();
12
+ @ Getter
13
+ private Mono <Void > first = Mono .empty ();
12
14
13
15
private boolean hasListener ;
14
16
@@ -17,12 +19,18 @@ public synchronized void async(Publisher<?> publisher) {
17
19
this .async = async .then (Mono .from (publisher ).then ());
18
20
}
19
21
22
+ @ Override
23
+ public synchronized void first (Publisher <?> publisher ) {
24
+ hasListener = true ;
25
+ this .first = Mono .from (publisher ).then (first );
26
+ }
27
+
20
28
@ Override
21
29
public Mono <Void > publish (ApplicationEventPublisher eventPublisher ) {
22
30
23
31
eventPublisher .publishEvent (this );
24
32
25
- return this .async ;
33
+ return this .first . then ( this . async ) ;
26
34
}
27
35
28
36
public boolean hasListener () {
You can’t perform that action at this time.
0 commit comments