Skip to content

JAVA-5505 minor refactoring #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public <A> void read(ByteBuffer dst, A attach, CompletionHandler<Integer, ? supe
new ByteBufferSet(dst),
0,
TimeUnit.MILLISECONDS,
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed((int) c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand All @@ -119,8 +119,8 @@ public <A> void read(
new ByteBufferSet(dst),
timeout,
unit,
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed((int) c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand All @@ -145,8 +145,8 @@ public <A> void read(
bufferSet,
timeout,
unit,
c -> group.executor.submit(() -> handler.completed(c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed(c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand Down Expand Up @@ -185,8 +185,8 @@ public <A> void write(ByteBuffer src, A attach, CompletionHandler<Integer, ? sup
new ByteBufferSet(src),
0,
TimeUnit.MILLISECONDS,
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed((int) c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand All @@ -205,8 +205,8 @@ public <A> void write(
new ByteBufferSet(src),
timeout,
unit,
c -> group.executor.submit(() -> handler.completed((int) c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed((int) c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand All @@ -228,8 +228,8 @@ public <A> void write(
bufferSet,
timeout,
unit,
c -> group.executor.submit(() -> handler.completed(c, attach)),
e -> group.executor.submit(() -> handler.failed(e, attach)));
c -> group.submit(() -> handler.completed(c, attach)),
e -> group.submit(() -> handler.failed(e, attach)));
}

@Override
Expand All @@ -251,11 +251,11 @@ public Future<Integer> write(ByteBuffer src) {
}

private <A> void completeWithZeroInt(A attach, CompletionHandler<Integer, ? super A> handler) {
group.executor.submit(() -> handler.completed(0, attach));
group.submit(() -> handler.completed(0, attach));
}

private <A> void completeWithZeroLong(A attach, CompletionHandler<Long, ? super A> handler) {
group.executor.submit(() -> handler.completed(0L, attach));
group.submit(() -> handler.completed(0L, attach));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static final class WriteOperation extends Operation {

private final Selector selector;

final ExecutorService executor;
private final ExecutorService executor;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stIncMale I can roll back the finals. The reduced visibility refactor would ensure that (in the near future) the user-set executor is not shut down from outside this class. Up to you - is this worth the potential future merge conflict?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something worth discussing the team on the catchup meeting, or asking Jeff/Ross here, as they are likely the only ones who have idea on our process of syncing the tlschannel code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force rebased. Removed finals commit, kept visibility commit.


private final ScheduledThreadPoolExecutor timeoutExecutor =
new ScheduledThreadPoolExecutor(
Expand Down Expand Up @@ -228,6 +228,10 @@ public AsynchronousTlsChannelGroup() {
this(Runtime.getRuntime().availableProcessors());
}

void submit(final Runnable r) {
executor.submit(r);
}

RegisteredSocket registerSocket(TlsChannel reader, SocketChannel socketChannel) {
if (shutdown != Shutdown.No) {
throw new ShutdownChannelGroupException();
Expand Down