Skip to content

Commit

Permalink
use newVirtualThreadPerTaskExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammad-salem committed Jan 20, 2025
1 parent 767e38a commit 957fb9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ public JavaHttpClient(Proxy proxy, String username, char[] password, boolean tru
var builder = HttpClient.newBuilder()
.followRedirects(Redirect.ALWAYS)
.connectTimeout(Duration.ofSeconds(20))
.proxy(new JavaProxySelector(proxy))
// .proxy(ProxySelector.of( (InetSocketAddress) proxy.address() ))
// .authenticator(Authenticator.getDefault())
// .executor(Executors.newCachedThreadPool())
;
.proxy(new JavaProxySelector(proxy));
if (!Proxy.NO_PROXY.equals(proxy) && proxy != null && username != null && password != null) {
var authenticator = new Authenticator() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public ChannelClient(Properties properties, ClientRequest clientRequest) {
this(
properties,
clientRequest,
Executors.newCachedThreadPool(),
Executors.newVirtualThreadPerTaskExecutor(),
new ClientChannelWriter() {}
);
}

public ChannelClient(Properties properties, ClientRequest clientRequest, ClientWriter clientWriter) {
this(properties, clientRequest, Executors.newCachedThreadPool(), new ChannelDownloader(clientRequest, clientWriter));
this(properties, clientRequest, Executors.newVirtualThreadPerTaskExecutor(), new ChannelDownloader(clientRequest, clientWriter));
}

public ChannelClient(Properties properties, ClientRequest clientRequest, ExecutorService executor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

public class SegmentClient extends Client implements StreamOrder, ThreadOrder {

private SegmentDownloader segmentDownloader;
private final SegmentDownloader segmentDownloader;

public SegmentClient(Properties properties, ClientRequest clientRequest) {
this(
properties,
clientRequest,
Executors.newCachedThreadPool(),
Executors.newVirtualThreadPerTaskExecutor(),
new SegmentDownloader(clientRequest, new SegmentWriter() {}))
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DownloadServiceBuilder builder() {
builder.setSessionReport(sessionReportFactory);
}
if (Objects.isNull(scheduledService)) {
this.scheduledService = Executors.newScheduledThreadPool(SCHEDULE_POOL);
this.scheduledService = Executors.newScheduledThreadPool(SCHEDULE_POOL, Thread.ofVirtual().factory());
}
builder.setScheduledService(scheduledService);
if (Objects.isNull(connectivityCheck)) {
Expand Down

0 comments on commit 957fb9b

Please sign in to comment.