From 8cc63bdd556de7c2b3056293d692f24f4dd4f8f5 Mon Sep 17 00:00:00 2001 From: CLFutureX <775523362@qq.com> Date: Thu, 15 Aug 2024 08:55:02 +0800 Subject: [PATCH] feat(s3stream): optimize eventLoop --- .../main/java/com/automq/stream/utils/threads/EventLoop.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java b/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java index 58dcf99aa4..566232a1bd 100644 --- a/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java +++ b/s3stream/src/main/java/com/automq/stream/utils/threads/EventLoop.java @@ -87,6 +87,11 @@ public CompletableFuture submit(Runnable task) { public void execute(Runnable task) { check(); tasks.add(task); + if (shutdown.get()) { + if (tasks.remove(task)) { + throw new IllegalStateException("EventLoop is shutdown"); + } + } } public CompletableFuture shutdownGracefully() {