FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Increase the probability for requests to Docker daemon to be executed consequently by tejksat · Pull Request #1491 · docker-java/docker-java · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or 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
Expand Up @@ -23,6 +23,7 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;

class DefaultInvocationBuilder implements InvocationBuilder {
Expand Down Expand Up @@ -264,7 +265,11 @@ protected <T> void executeAndStream(
ResultCallback<T> callback,
Consumer<DockerHttpClient.Response> sourceConsumer
) {
CountDownLatch threadStarted = new CountDownLatch(1);

Thread thread = new Thread(() -> {
threadStarted.countDown();

Thread streamingThread = Thread.currentThread();
try (DockerHttpClient.Response response = execute(request)) {
callback.onStart(() -> {
Expand All @@ -281,6 +286,13 @@ protected <T> void executeAndStream(
thread.setDaemon(true);

thread.start();

try {
// wait while the thread is actually started to let the request a better chances to be executed prior to a next request
threadStarted.await();
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
}

private InputStream encode(Object entity) {
Expand Down

Back | FazBrowse Home | New Git URL