Skip to content

Commit

Permalink
Make ActionDispatcher more easily customizable
Browse files Browse the repository at this point in the history
- Extract thread creation and initialization out of constructor
  • Loading branch information
martin-fleck-at committed Jun 18, 2024
1 parent e7713ee commit 501429e
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.LogManager;
import java.util.stream.Collectors;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.glsp.server.actions.Action;
import org.eclipse.glsp.server.actions.ActionDispatcher;
import org.eclipse.glsp.server.actions.ActionHandler;
Expand Down Expand Up @@ -87,11 +86,23 @@ public class DefaultActionDispatcher extends Disposable implements ActionDispatc
protected Provider<GLSPClient> client;

public DefaultActionDispatcher() {
this.initialize();
}

protected void initialize() {
this.name = getClass().getSimpleName() + " " + COUNT.incrementAndGet();
this.thread = new Thread(this::runThread);
this.thread.setName(this.name);
this.thread.setDaemon(true);
this.thread.start();
this.thread = this.createThread();
this.initializeThread(thread, name);
thread.start();
}

protected Thread createThread() {
return new Thread(this::runThread);
}

protected void initializeThread(final Thread thread, final String name) {
thread.setName(name);
thread.setDaemon(true);
}

@Override
Expand Down

0 comments on commit 501429e

Please sign in to comment.