Skip to content

Commit

Permalink
Drop delay, break all schedule method calls
Browse files Browse the repository at this point in the history
Bump version to 0.2.0, this breaks all existing method calls. DelayJob() was completely dropped.
  • Loading branch information
virustotalop committed Oct 20, 2019
1 parent 8481665 commit fe7d209
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {
maven { url 'https://jitpack.io' }
}
compile 'com.github.clubobsidian:crouton:0.1.0'
compile 'com.github.clubobsidian:crouton:0.2.0'
```

### Maven
Expand All @@ -47,6 +47,6 @@ compile 'com.github.clubobsidian:crouton:0.1.0'
<dependency>
<groupId>com.github.clubobsidian</groupId>
<artifactId>crouton</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
</dependency>
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.clubobsidian'
version '0.1.0'
version '0.2.0'

sourceCompatibility = 1.8

Expand Down
26 changes: 18 additions & 8 deletions src/main/kotlin/com/clubobsidian/crouton/Crouton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Crouton public constructor() {
private var job: Job? = null;
private val running = AtomicBoolean(true);

fun createAsyncJob(runnable : Runnable) : Job {
fun async(runnable : Runnable) : Job {
if(this.job == null) {
val newJob = GlobalScope.launch() {
async {
Expand All @@ -41,7 +41,21 @@ class Crouton public constructor() {
return this.job!!;
}

fun createAsyncRepeatingJob(runnable: Runnable, initialDelay : Long, repeatingDelay : Long) : Job {
fun asyncDelayed(runnable : Runnable, delay: Long) : Job {
if(this.job == null) {
val newJob = GlobalScope.launch() {
async {
delay(delay);
runnable.run();
}
};

this.job = newJob;
}
return this.job!!;
}

fun asyncRepeating(runnable: Runnable, initialDelay : Long, repeatingDelay : Long) : Job {
if(this.job == null) {
val newJob = GlobalScope.launch() {
async {
Expand All @@ -58,9 +72,9 @@ class Crouton public constructor() {
return this.job!!;
}

fun createAsyncWait(future: Future<Any>) : Future<Any> {
fun await(future: Future<Any>) : Future<Any> {
val completedFuture = CompletableFuture<Any>();
if(this.job == null) {
if (this.job == null) {
val newJob = GlobalScope.launch() {
async {
completedFuture.complete(future.get());
Expand All @@ -71,10 +85,6 @@ class Crouton public constructor() {
return future;
}

suspend fun delayJob(millis: Long) {
delay(millis);
}

fun isRunning() : AtomicBoolean {
return this.running;
}
Expand Down

0 comments on commit fe7d209

Please sign in to comment.