From d81f2718e8f06984039e9ab2c84c23ca0462c248 Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 24 Feb 2025 21:22:19 +0800 Subject: [PATCH 1/2] edit RingBufferTest --- .../xtool/core/collection/RingBufferTest.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/igeeksky/xtool/core/collection/RingBufferTest.java b/src/test/java/com/igeeksky/xtool/core/collection/RingBufferTest.java index 57491ed..5440aca 100644 --- a/src/test/java/com/igeeksky/xtool/core/collection/RingBufferTest.java +++ b/src/test/java/com/igeeksky/xtool/core/collection/RingBufferTest.java @@ -377,7 +377,7 @@ void test_TwoOffer_TwoConsumer_Concurrently() throws InterruptedException { @Test void test_TwoOffer_OnePoll_Concurrently() throws InterruptedException { - RingBuffer buffer = new RingBuffer<>(2048); + RingBuffer buffer = new RingBuffer<>(1000); StringConsumer consumer = new StringConsumer(); CountDownLatch latch = new CountDownLatch(2); @@ -402,7 +402,7 @@ void test_TwoOffer_OnePoll_Concurrently() throws InterruptedException { thread1.start(); thread2.start(); - latch.await(2000, TimeUnit.MILLISECONDS); + LockSupport.parkNanos(10); for (int i = 0; i < 2001; i++) { String polled = buffer.poll(); @@ -413,6 +413,21 @@ void test_TwoOffer_OnePoll_Concurrently() throws InterruptedException { assertEquals(consumer.getCount(), buffer.reads()); } + System.out.println("buffer.reads()1:" + buffer.reads()); + + boolean ignored = latch.await(100, TimeUnit.MILLISECONDS); + + for (int i = 0; i < 2001; i++) { + String polled = buffer.poll(); + if (polled != null) { + consumer.accept(polled); + continue; + } + assertEquals(consumer.getCount(), buffer.reads()); + } + + System.out.println("buffer.reads()2:" + buffer.reads()); + Set values = consumer.getValues(); for (int i = 0; i < 2000; i++) { String element = "element" + i; From 32d94c14ba6aba46a0aa0adf0dc776bd8c85ed9c Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 24 Feb 2025 21:23:55 +0800 Subject: [PATCH 2/2] 1.1.4 --- README.md | 8 ++++++-- docs/Reference.md | 6 +++--- pom.xml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fa49c20..f8d4dfa 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,14 @@ xtool 是一个小小的 Java 工具集,遵循简单、可靠的原则,不 com.igeeksky.xtool xtool - 1.1.3 + 1.1.4 ``` ### 2.2.Gradle ```groovy -implementation group: 'com.igeeksky.xtool', name: 'xtool', version: '1.1.3' +implementation group: 'com.igeeksky.xtool', name: 'xtool', version: '1.1.4' ``` ### 2.3.编译安装 @@ -80,6 +80,10 @@ mvn clean install ## 4. 更新日志 +### 1.1.3 + +1. add AsyncCloseable API + ### 1.1.2 1. add Shutdown API diff --git a/docs/Reference.md b/docs/Reference.md index f67f46f..630d2be 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -1,6 +1,6 @@ ## xtool 参考文档 -Author: [Patrick.Lau](mailto:patricklauxx@gmail.com) Version: 1.1.3 +Author: [Patrick.Lau](mailto:patricklauxx@gmail.com) Version: 1.1.4 [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) [![Release](https://img.shields.io/github/v/release/patricklaux/xtool)](https://github.com/patricklaux/xtool/releases) [![Maven Central](https://img.shields.io/maven-central/v/com.igeeksky.xtool/xtool.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.igeeksky.xtool%22%20AND%20a:%22xtool%22) [![codecov](https://codecov.io/gh/patricklaux/xtool/branch/main/graph/badge.svg?token=VJ87A1IAVH)](https://codecov.io/gh/patricklaux/xtool) [![Last commit](https://img.shields.io/github/last-commit/patricklaux/xtool)](https://github.com/patricklaux/xtool/commits) [![Join the chat at https://gitter.im/igeeksky/xtool](https://badges.gitter.im/igeeksky/xtool.svg)](https://gitter.im/igeeksky/xtool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -26,14 +26,14 @@ xtool 是一个小小的 Java 工具集,遵循简单、可靠的原则,不 com.igeeksky.xtool xtool - 1.1.3 + 1.1.4 ``` #### 1.2.2.Gradle ```groovy -implementation group: 'com.igeeksky.xtool', name: 'xtool', version: '1.1.3' +implementation group: 'com.igeeksky.xtool', name: 'xtool', version: '1.1.4' ``` #### 1.2.3.编译安装 diff --git a/pom.xml b/pom.xml index 931e63a..e552035 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.igeeksky.xtool xtool - 1.1.3 + 1.1.4 xtool xtool is a very small set of Java tools. https://github.com/patricklaux/xtool