-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
2,247 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
openjdk8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 8 | ||
- run: ./gradlew check |
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,23 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: published | ||
|
||
jobs: | ||
openjdk8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 8 | ||
- run: ./gradlew jar | ||
- run: ./gradlew publish -Pversion=${GITHUB_REF##*/} -P'signing.keyId=${{ secrets.signingKeyId }}' -P'signing.password=${{ secrets.signingPassword }}' -P'sonatypeUsername=${{ secrets.sonatypeUsername }}' -P'sonatypePassword=${{ secrets.sonatypePassword }}' |
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,19 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
|
||
out | ||
build | ||
.gradle | ||
.idea | ||
*.iml | ||
|
||
/local.properties | ||
|
||
/.gradletasknamecache | ||
|
||
*.log | ||
**/*.log | ||
|
||
tmp | ||
**/libs | ||
|
||
transaction-logs |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,70 @@ | ||
# YaaTask4j | ||
Yet another async task manager for java to simplify multi-thread task execution on Java | ||
Yet another async task manager for java to simplify multi-thread task execution on Java. | ||
|
||
### Setup | ||
* Maven | ||
``` | ||
<dependency> | ||
<groupId>org.laxture</groupId> | ||
<artifactId>yaaTask4j</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
``` | ||
* Gradle | ||
``` | ||
dependencies { | ||
implementation 'org.laxture:yaaTask4j:0.1.0' | ||
} | ||
``` | ||
### Usage | ||
```java | ||
ImmediateTaskManager.getInstance().queue(TaskBuilder.build(() -> { | ||
// hello world | ||
})); | ||
``` | ||
|
||
### Features | ||
* `YaaTasks` with same id will be executed only once in a `TaskManager` | ||
* `TaskManager` interface | ||
* Execution | ||
* `queue(task)` put the task to the end of execution queue. | ||
* `queueAndAwait(task)` put the task to the end of execution queue and wait for it finished. | ||
* `push(task)` put the task to the head of execution queue. | ||
* `pushAndAwait(task)` put the task to the head of execution queue and wait for it finished. | ||
* Management | ||
* `getRunningTaskCount()` get currently running tasks count. | ||
* `getPendingTaskCount()` get currently pending tasks count. | ||
* `getRunningTasks()` get currently running tasks | ||
* `getPendingTasks()` get currently pending tasks | ||
* `getAllTasks()` get all tasks | ||
* `findTask(taskId)` find task by task id | ||
* `findTaskInQueue(taskId)` find pending task by task id | ||
* `cancelAll()` cancel all tasks execution, include running tasks | ||
* `cancelByTag(taskTag)` cancel tasks by provided tag execution, include running tasks | ||
* `cancel(task)` cancel specific task execution | ||
* Three `TaskManager` is provided for different purposes | ||
* `ImmediateTaskManager` runs task immediately. | ||
* `SerialTaskManager` runs task one by one in serial. | ||
* `QueueTaskManager` runs task in a concurrent queue, maximum concurrent count is default | ||
to host machine's CPU core count. | ||
|
||
### License | ||
|
||
``` | ||
/* | ||
* Copyright (C) 2019-present the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
``` |
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,188 @@ | ||
def checkProperty(Project project, String propName) { | ||
if (!project.hasProperty(propName)) return false | ||
String prop = project.property(propName) | ||
return prop != null && prop.length() > 0 | ||
} | ||
|
||
def getPropertyOrElse(Project project, String propName, String alternative) { | ||
if (!checkProperty(project, propName)) return alternative | ||
return project.property(propName) | ||
} | ||
|
||
buildscript { | ||
ext.lombokVersion = '1.18.8' | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'ch.raffael.markdown-doclet:markdown-doclet:1.4' | ||
} | ||
} | ||
|
||
plugins { | ||
id 'idea' | ||
} | ||
|
||
//************************************************************************* | ||
// IDEA | ||
//************************************************************************* | ||
|
||
idea { | ||
module { | ||
inheritOutputDirs = true | ||
downloadSources = true | ||
} | ||
} | ||
|
||
//************************************************************************* | ||
// Sub Project Config | ||
//************************************************************************* | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'jacoco' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
//************************************************************************* | ||
// Properties | ||
//************************************************************************* | ||
|
||
Properties localProp = new Properties() | ||
try { | ||
localProp.load(project.rootProject.file('local.properties').newDataInputStream()) | ||
} catch(Exception ignored) {} | ||
for (String propKey in localProp.keys()) { | ||
ext.set(propKey, localProp.get(propKey)) | ||
} | ||
ext."signing.secretKeyRingFile" = rootProject.file('publish.gpg') | ||
|
||
task setProperties { | ||
doFirst { | ||
project.ext.executable = "$project.name" | ||
} | ||
} | ||
|
||
//************************************************************************* | ||
// Compile & Assemble | ||
//************************************************************************* | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
tasks.withType(AbstractCompile) { | ||
options.encoding = 'UTF-8' | ||
} | ||
tasks.withType(Javadoc) { | ||
options.encoding = 'UTF-8' | ||
} | ||
|
||
jar { | ||
manifest.attributes provider: 'gradle' | ||
enabled true | ||
doFirst { | ||
archiveFileName = "$project.name-$version.${archiveExtension.get()}" | ||
} | ||
} | ||
|
||
test { | ||
testLogging.showStandardStreams = true | ||
workingDir = project.rootDir | ||
testLogging { | ||
events "failed" | ||
exceptionFormat "short" | ||
} | ||
} | ||
|
||
dependencies { | ||
compile "org.projectlombok:lombok:${lombokVersion}" | ||
annotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" | ||
implementation 'com.networknt:slf4j-logback:2.0.32' | ||
implementation 'org.apache.commons:commons-lang3:3.12.0' | ||
|
||
testImplementation 'junit:junit:4.13.2' | ||
} | ||
|
||
//************************************************************************* | ||
// Maven | ||
//************************************************************************* | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
archiveClassifier.set('sources') | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
archiveClassifier.set('javadoc') | ||
from javadoc.destinationDir | ||
} | ||
|
||
artifacts { | ||
archives jar | ||
archives sourcesJar | ||
archives javadocJar | ||
} | ||
|
||
group = 'org.laxture' | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
groupId = project.getGroup() | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
pom { | ||
name = project.name | ||
description = 'Yet another async task manager for java to simplify multi-thread task execution on Java.' | ||
url = 'https://github.com/hank-cp/yaaTask4j' | ||
organization { | ||
name = 'org.laxture' | ||
url = 'https://laxture.org' | ||
} | ||
issueManagement { | ||
system = 'GitHub' | ||
url = 'https://github.com/hank-cp/yaaTask4j/issues' | ||
} | ||
license { | ||
name = 'Apache License 2.0' | ||
url = 'https://github.com/hank-cp/yaaTask4j/blob/master/LICENSE' | ||
distribution = 'repo' | ||
} | ||
scm { | ||
url = 'https://github.com/hank-cp/yaaTask4j' | ||
connection = 'scm:git:git://github.com/hank-cp/yaaTask4j.git' | ||
developerConnection = 'scm:git:ssh://git@github.com:hank-cp/yaaTask4j.git' | ||
} | ||
developers { | ||
developer { | ||
name = 'Hank CP' | ||
email = 'true.cp@gmail.com' | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" | ||
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl | ||
credentials { | ||
username getPropertyOrElse(project, 'sonatypeUsername', '') | ||
password getPropertyOrElse(project, 'sonatypePassword', '') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign publishing.publications.mavenJava | ||
} |
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,3 @@ | ||
org.gradle.daemon=true | ||
|
||
version=0.1.0 |
Binary file not shown.
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,6 @@ | ||
#Thu Jan 17 21:21:01 CST 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip |
Oops, something went wrong.