Skip to content

Commit 226469d

Browse files
重构完成,完善文档
1 parent 1043e74 commit 226469d

16 files changed

Lines changed: 1240 additions & 1231 deletions

README.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
![Gradle 8.10.2](https://img.shields.io/badge/Gradle-8.10.2-04303b.svg "tool")
99
![Apache 2](https://img.shields.io/badge/license-Apache%202-blue.svg "License")
1010

11-
-- [Java Doc](https://apidoc.gitee.com/fybug/PDConcurrent) --
11+
[//]: # (-- [Java Doc](https://apidoc.gitee.com/fybug/PDConcurrent) --)
1212

13-
-- [项目主页](https://fybug.gitee.io/projectsby/PDConcurrent.html) --
13+
[//]: # (-- [项目主页](https://fybug.gitee.io/projectsby/PDConcurrent.html) --)
1414

1515
-------------------------------------------------------------------------------
1616

17-
**专注于单个功能,无附加bug**
18-
1917
## 简介
2018

2119
轻量级,高可靠,易学习的并发管理工具。
@@ -24,12 +22,15 @@
2422

2523
如果你已经熟悉 java 的多线程管理,尤其是 ReentrantReadWriteLock 读写锁的话你会更容易学会本工具。
2624

27-
本工具采用读写锁标准,无论内部实现如何,外部接口均提供 **read, **write 方法区分读锁并发域和写锁并发域
25+
无论内部实现如何,外部接口均提供 **read, **write 方法区分读锁并发域和写锁并发域
2826

2927
### 基础使用示例
28+
3029
```java
31-
public static void main(String[] args) {
32-
var lock = SyLock.newObjLock();
30+
public final SyLock lock = SyLock.newObjLock();
31+
32+
public static
33+
void main(String[] args) {
3334
lock.read(() -> {
3435
// 并发域代码内容
3536
[return null;]? // 可选择是否返回
@@ -46,10 +47,13 @@ public static void main(String[] args) {
4647
可通过接口的工厂方法实例化内部采用不同实现的锁。
4748

4849
### synchronized 锁
50+
4951
```java
50-
public static void main(String[] args) {
52+
public final SyLock lock = SyLock.newObjLock();
53+
54+
public static
55+
void main(String[] args) {
5156
// 使用
52-
var lock = SyLock.newObjLock();
5357
lock.read(() -> {
5458
// 并发域代码内容
5559
});
@@ -63,10 +67,16 @@ public static void main(String[] args) {
6367
```
6468

6569
### ReentrantLock 锁
70+
71+
支持使用`newCondition()`获取`Condition`对象
72+
73+
支持通过`isLocked()`检查是否被占用
74+
6675
```java
67-
public static void main(String[] args) {
76+
public static
77+
void main(String[] args) {
6878
// 使用
69-
var lock = SyLock.newReLock();
79+
SyLock lock = SyLock.newReLock();
7080
lock.read(() -> {
7181
// 并发域代码内容
7282
});
@@ -83,10 +93,18 @@ public static void main(String[] args) {
8393
```
8494

8595
### ReadWriteLock 锁
96+
97+
支持通过`toread()`进行写锁 => 读锁降级
98+
99+
支持使用`newReadCondition()` `newWriteCondition()`获取`Condition`对象
100+
101+
支持通过`isLocked()` `isWriteLocked()` `isReadLocked()`检查是否被占用
102+
86103
```java
87-
public static void main(String[] args) {
104+
public static
105+
void main(String[] args) {
88106
// 使用
89-
var lock = SyLock.newRWLock();
107+
SyLock lock = SyLock.newRWLock();
90108
lock.read(() -> {
91109
// 并发域代码内容
92110
});
@@ -103,17 +121,19 @@ public static void main(String[] args) {
103121
```
104122

105123
## 使用方法
124+
106125
请导入其 `jar` 文件,文件在 **发行版** 或项目的 **jar** 文件夹下可以找到
107126

108-
> PDConcurrent.jar 为不包含源码的包
127+
> PDConcurrent_bin.jar 为编译包
109128
>
110-
> PDConcurrent_sources.jar 为仅包含源码的包
129+
> PDConcurrent_sources.jar 为源码包
111130
112131
**发行版中可以看到全部版本<br/>项目下的 jar 文件夹是当前最新的每夜版**
113132

114133
可通过 **WIKI** 或者 **doc文档** 深入学习本工具
115134

116135
## 分支说明
136+
117137
**dev-master**:当前的开发分支,可以拿到最新的每夜版 jar
118138

119139
**releases**:当前发布分支,稳定版的源码

build.gradle

Lines changed: 75 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,113 @@
11
plugins {
2-
id 'java'
3-
id 'idea'
2+
id 'java'
3+
id 'idea'
44
}
55

66
tasks.withType(JavaCompile).configureEach {
7-
options.encoding = "UTF-8"
7+
options.encoding = "UTF-8"
88
}
99

1010
group 'fybug.nulll'
1111
version = '0.1.0'
1212

1313
java {
14-
toolchain {
15-
languageVersion = JavaLanguageVersion.of(23)
16-
}
14+
toolchain {
15+
languageVersion = JavaLanguageVersion.of(23)
16+
}
1717
}
1818

1919
repositories {
20-
mavenLocal()
21-
mavenCentral()
22-
google()
23-
maven { url 'https://maven.aliyun.com/repository/releases' }
24-
maven { url "https://maven.aliyun.com/repository/jcenter" }
25-
maven { url "https://maven.aliyun.com/repository/mapr-public" }
26-
maven { url "https://maven.aliyun.com/repository/staging-alpha" }
27-
maven { url "https://maven.aliyun.com/repository/central" }
28-
maven { url "https://maven.aliyun.com/repository/public/" }
29-
maven { url "https://maven.aliyun.com/repository/google" }
30-
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
31-
maven { url "https://maven.aliyun.com/repository/spring" }
32-
maven { url "https://maven.aliyun.com/repository/spring-plugin" }
33-
maven { url "https://maven.aliyun.com/repository/grails-core" }
34-
maven { url "https://maven.aliyun.com/repository/snapshots" }
35-
maven { url "https://maven.aliyun.com/repository/apache-snapshots" }
36-
maven { url "https://maven.aliyun.com/repository/staging-alpha-group" }
20+
mavenLocal()
21+
mavenCentral()
22+
google()
23+
maven { url 'https://maven.aliyun.com/repository/releases' }
24+
maven { url "https://maven.aliyun.com/repository/jcenter" }
25+
maven { url "https://maven.aliyun.com/repository/mapr-public" }
26+
maven { url "https://maven.aliyun.com/repository/staging-alpha" }
27+
maven { url "https://maven.aliyun.com/repository/central" }
28+
maven { url "https://maven.aliyun.com/repository/public/" }
29+
maven { url "https://maven.aliyun.com/repository/google" }
30+
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
31+
maven { url "https://maven.aliyun.com/repository/spring" }
32+
maven { url "https://maven.aliyun.com/repository/spring-plugin" }
33+
maven { url "https://maven.aliyun.com/repository/grails-core" }
34+
maven { url "https://maven.aliyun.com/repository/snapshots" }
35+
maven { url "https://maven.aliyun.com/repository/apache-snapshots" }
36+
maven { url "https://maven.aliyun.com/repository/staging-alpha-group" }
3737
}
3838

3939
dependencies {
40-
// 本地依赖
41-
implementation fileTree(dir: 'lib', includes: ['*.jar'])
40+
// 本地依赖
41+
implementation fileTree(dir: 'lib', includes: ['*.jar'])
4242

43-
// 注释包
44-
compileOnly "jakarta.validation:jakarta.validation-api:+"
45-
compileOnly "jakarta.annotation:jakarta.annotation-api:+"
46-
// lombok
47-
compileOnly 'org.projectlombok:lombok:+'
48-
annotationProcessor 'org.projectlombok:lombok:+'
43+
// 注释包
44+
compileOnly "jakarta.validation:jakarta.validation-api:+"
45+
compileOnly "jakarta.annotation:jakarta.annotation-api:+"
46+
// lombok
47+
compileOnly 'org.projectlombok:lombok:+'
48+
annotationProcessor 'org.projectlombok:lombok:+'
4949

50-
// 注释包
51-
testCompileOnly "jakarta.validation:jakarta.validation-api:+"
52-
testCompileOnly "jakarta.annotation:jakarta.annotation-api:+"
53-
// lombok
54-
testCompileOnly "org.projectlombok:lombok:+"
55-
testAnnotationProcessor "org.projectlombok:lombok:+"
56-
// testImplementation "junit:junit"
50+
// 注释包
51+
testCompileOnly "jakarta.validation:jakarta.validation-api:+"
52+
testCompileOnly "jakarta.annotation:jakarta.annotation-api:+"
53+
// lombok
54+
testCompileOnly "org.projectlombok:lombok:+"
55+
testAnnotationProcessor "org.projectlombok:lombok:+"
56+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
5757
}
5858

5959
test {
60-
useJUnitPlatform()
60+
dependencies {
61+
testImplementation "org.junit.platform:junit-platform-launcher"
62+
}
63+
useJUnitPlatform()
6164
}
6265

6366
/** 清单文件内容 */
6467
tasks.withType(Jar).configureEach {
65-
manifest {
66-
attributes('Manifest-Version': '1.0',
67-
'Built-By': 'fybug/风雨bu改',
68-
'Build-Jdk-Spec': 23,
69-
'Bundle-Description': 'java并发控制工具',
70-
'Bundle-Name': 'PDConcurrent',
71-
// 'Bundle-DocURL': 'https://apidoc.gitee.com/fybug/PDConcurrent/',
72-
'Bundle-Vendor': 'IntelliJ IDEA',
73-
'Bundle-Version': version,
74-
'Bundle-License': 'https://www.apache.org/licenses/LICENSE-2.0',
75-
'Created-By': 'Gradle 8.10.2')
76-
}
68+
destinationDirectory = file('jar')
69+
manifest {
70+
attributes('Manifest-Version': '1.0',
71+
'Built-By': 'fybug/风雨bu改',
72+
'Build-Jdk-Spec': 23,
73+
'Bundle-Description': 'java并发控制工具',
74+
'Bundle-Name': 'PDConcurrent',
75+
// 'Bundle-DocURL': 'https://apidoc.gitee.com/fybug/PDConcurrent/',
76+
'Bundle-Vendor': 'IntelliJ IDEA',
77+
'Bundle-Version': version,
78+
'Bundle-License': 'https://www.apache.org/licenses/LICENSE-2.0',
79+
'Created-By': 'Gradle 8.10.2')
80+
}
7781
}
7882

7983
/** 编译包 */
8084
tasks.register('PDConcurrent_bin', Jar) {
81-
dependsOn classes
82-
destinationDirectory = file('jar')
83-
archiveFileName = 'PDConcurrent_bin.jar'
84-
archiveClassifier = ''
85-
// 打包编译输出
86-
from sourceSets.main.output
85+
archiveFileName = 'PDConcurrent_bin.jar'
86+
archiveClassifier = ''
87+
// 打包编译输出
88+
from sourceSets.main.output
8789
}
8890

8991
/** 源码包 */
9092
tasks.register('PDConcurrent_sources', Jar) {
91-
dependsOn classes
92-
destinationDirectory = file('jar')
93-
archiveFileName = 'PDConcurrent_sources.jar'
94-
archiveClassifier = 'sources'
95-
// 打包源码
96-
from sourceSets.main.allSource
93+
archiveFileName = 'PDConcurrent_sources.jar'
94+
archiveClassifier = 'sources'
95+
// 打包源码
96+
from sourceSets.main.allSource
9797
}
9898

99-
tasks.register('PDConcurrent_all', Jar) {
100-
dependsOn classes
101-
destinationDirectory = file('jar')
102-
archiveFileName = 'PDConcurrent_all.jar'
103-
archiveClassifier = 'all'
104-
// 打包编译输出
105-
from sourceSets.main.output
106-
from {
107-
// implementation 相关的引入解压并打包入新的jar中
108-
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
109-
}
110-
}
99+
//tasks.register('PDConcurrent_all', Jar) {
100+
// archiveFileName = 'PDConcurrent_all.jar'
101+
// archiveClassifier = 'all'
102+
// // 打包编译输出
103+
// from sourceSets.main.output
104+
// from {
105+
// // implementation 相关的引入解压并打包入新的jar中
106+
// configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
107+
// }
108+
//}
111109

112110
tasks.register('release') {
113-
dependsOn clean
114-
dependsOn PDConcurrent_bin
115-
dependsOn PDConcurrent_sources
111+
dependsOn PDConcurrent_bin
112+
dependsOn PDConcurrent_sources
116113
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
3+
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.10.2-bin.zip
4+
#distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
45
networkTimeout=10000
56
validateDistributionUrl=true
67
zipStoreBase=GRADLE_USER_HOME

jar/PDConcurrent_bin.jar

-535 Bytes
Binary file not shown.

jar/PDConcurrent_sources.jar

30 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)