-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* http: use virtual thread to replace undertow worker pool
Signed-off-by: neo <[email protected]>
- Loading branch information
Showing
12 changed files
with
106 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
core-ng/src/main/java/core/framework/internal/async/VirtualThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package core.framework.internal.async; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class VirtualThread { | ||
public static final Stats STATS = new Stats(); | ||
|
||
public static class Stats { | ||
final AtomicInteger count = new AtomicInteger(0); | ||
final AtomicInteger maxCount = new AtomicInteger(0); | ||
|
||
public void increase() { | ||
int current = count.incrementAndGet(); | ||
maxCount.getAndAccumulate(current, Math::max); // only increase active request triggers max active request process, doesn't need to handle when active requests decrease | ||
} | ||
|
||
public int maxCount() { | ||
return maxCount.getAndSet(count.get()); | ||
} | ||
|
||
public void decrease() { | ||
count.decrementAndGet(); | ||
} | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
core-ng/src/main/java/core/framework/internal/async/VirtualThreads.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core-ng/src/test/java/core/framework/internal/async/VirtualThreadStatsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package core.framework.internal.async; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class VirtualThreadStatsTest { | ||
private VirtualThread.Stats stats; | ||
|
||
@BeforeEach | ||
void createStats() { | ||
stats = new VirtualThread.Stats(); | ||
} | ||
|
||
@Test | ||
void maxCount() { | ||
stats.increase(); | ||
stats.increase(); | ||
stats.decrease(); | ||
assertThat(stats.maxCount()).isEqualTo(2); | ||
assertThat(stats.maxCount()).isEqualTo(1); | ||
} | ||
} |