Skip to content

Commit

Permalink
Further clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
hassieswift621 committed Mar 8, 2019
1 parent ad86e00 commit 01c7275
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ Dependencies
------------
The library is available on JCenter. The latest version is 2.1.0.

Replace ``{LATEST-VERSION}`` with the latest version.

**Gradle setup**
```gradle
implementation 'uk.co.hassie.libraries:async-threader:<LATEST-VERSION>'
implementation 'uk.co.hassie.libraries:async-threader:{LATEST-VERSION}'
```

**Maven setup**
```maven
<dependency>
<groupId>uk.co.hassie.libraries</groupId>
<artifactId>async-threader</artifactId>
<version><LATEST-VERSION></version>
<version>{LATEST-VERSION}</version>
<type>pom</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

group = 'uk.co.hassie.libraries'
version = '2.1.0'
version = '2.2.0'

apply plugin: 'java'
apply plugin: 'com.novoda.bintray-release'
Expand All @@ -35,7 +35,7 @@ publish {
userOrg = 'hassieswift621'
groupId = 'uk.co.hassie.libraries'
artifactId = 'async-threader'
publishVersion = '2.1.0'
publishVersion = '2.2.0'
desc = 'A type-safe Java async threader which automatically executes callbacks after a callable or future completes or fails.'
website = 'https://github.com/hassieswift621/async-threader'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class AsyncThreader {

private ExecutorService mExecutorService;
private ExecutorService executorService;

public static class Builder {

Expand Down Expand Up @@ -60,7 +60,7 @@ public AsyncThreader build() {
* Creates the async threader instance with default options.
*/
public AsyncThreader() {
mExecutorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
}

/**
Expand All @@ -69,7 +69,7 @@ public AsyncThreader() {
* @param threadPoolSize The thread pool size.
*/
private AsyncThreader(int threadPoolSize) {
mExecutorService = Executors.newFixedThreadPool(threadPoolSize);
executorService = Executors.newFixedThreadPool(threadPoolSize);
}


Expand All @@ -79,7 +79,7 @@ private AsyncThreader(int threadPoolSize) {
* @param request The request to execute.
*/
public <T> void execute(Request<T> request) {
mExecutorService.submit(request);
executorService.submit(request);
}

/**
Expand All @@ -101,7 +101,7 @@ public <T> CompletableFuture<T> execute(Callable<T> callable) {
);

// Execute request.
mExecutorService.submit(request);
executorService.submit(request);

return future;
}
Expand All @@ -113,14 +113,14 @@ public <T> CompletableFuture<T> execute(Callable<T> callable) {
*/
public void execute(Runnable runnable) {
// Execute request.
mExecutorService.submit(runnable);
executorService.submit(runnable);
}

/**
* Shutdown the async threader's executor service.
*/
public void shutdown() {
mExecutorService.shutdown();
executorService.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class Request<T> extends FutureTask<T> {

private final Response<T> mResponse;
private final Error mError;
private final Response<T> response;
private final Error error;

/**
* Create a request.
Expand All @@ -34,21 +34,22 @@ public class Request<T> extends FutureTask<T> {
*/
public Request(Callable<T> callable, Response<T> response, Error error) {
super(callable);
mResponse = response;
mError = error;
this.response = response;
this.error = error;
}

/**
* Run the callback after the task is completed.
* Executes the callbacks after task has completed.
*/
@Override
protected void done() {
try {
mResponse.onResponse(this.get());
this.response.onResponse(this.get());
} catch (InterruptedException e) {
mError.onError(e);
this.error.onError(e);
} catch (ExecutionException e) {
mError.onError(e.getCause());
this.error.onError(e.getCause());
}
}

}
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

group = 'uk.co.hassie.libraries'
version = '2.1.0'
version = '2.2.0'

apply plugin: 'java'

Expand Down

0 comments on commit 01c7275

Please sign in to comment.