Skip to content

Commit 75c4bbe

Browse files
authored
Merge pull request koush#488 from FiftyTwoDegreesNorth/issue-487
koush#487 Separate worker for DNS resolve
2 parents 262beab + 7e6c9d0 commit 75c4bbe

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

AndroidAsync/src/com/koushikdutta/async/AsyncServer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public void removeAllCallbacks(Object scheduled) {
129129
}
130130
}
131131

132+
private static ExecutorService synchronousWorkers = newSynchronousWorkers("AsyncServer-worker-");
132133
private static void wakeup(final SelectorWrapper selector) {
133134
synchronousWorkers.execute(new Runnable() {
134135
@Override
@@ -418,8 +419,8 @@ public Cancellable connectSocket(final String host, final int port, final Connec
418419
return connectSocket(InetSocketAddress.createUnresolved(host, port), callback);
419420
}
420421

421-
private static ExecutorService newSynchronousWorkers() {
422-
ThreadFactory tf = new NamedThreadFactory("AsyncServer-worker-");
422+
private static ExecutorService newSynchronousWorkers(String prefix) {
423+
ThreadFactory tf = new NamedThreadFactory(prefix);
423424
ThreadPoolExecutor tpe = new ThreadPoolExecutor(1, 4, 10L,
424425
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), tf);
425426
return tpe;
@@ -438,10 +439,10 @@ public int compare(InetAddress lhs, InetAddress rhs) {
438439
}
439440
};
440441

441-
private static ExecutorService synchronousWorkers = newSynchronousWorkers();
442+
private static ExecutorService synchronousResolverWorkers = newSynchronousWorkers("AsyncServer-resolver-");
442443
public Future<InetAddress[]> getAllByName(final String host) {
443444
final SimpleFuture<InetAddress[]> ret = new SimpleFuture<InetAddress[]>();
444-
synchronousWorkers.execute(new Runnable() {
445+
synchronousResolverWorkers.execute(new Runnable() {
445446
@Override
446447
public void run() {
447448
try {

AndroidAsyncSample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ android {
1919
}
2020

2121
compileSdkVersion 24
22-
buildToolsVersion "24.0.0"
22+
buildToolsVersion "24.0.2"
2323
}
2424

AndroidAsyncStetho/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525
}
2626

2727
compileSdkVersion 24
28-
buildToolsVersion '24.0.0'
28+
buildToolsVersion '24.0.2'
2929
}
3030

3131
// upload to maven task

0 commit comments

Comments
 (0)