-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a configuration option to customize engine-created threads, and provides a default implementation that will register those threads for debugging with pydevd if python is enabled. As of this commit, pydevd debugging seems to work correctly, but VSCode's debugging doesn't work for all threads yet. Partial #2997
- Loading branch information
Showing
13 changed files
with
188 additions
and
181 deletions.
There are no files selected for viewing
117 changes: 0 additions & 117 deletions
117
Util/src/main/java/io/deephaven/util/ExpandingThreadPoolExecutorFactory.java
This file was deleted.
Oops, something went wrong.
This file contains 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
45 changes: 45 additions & 0 deletions
45
Util/src/main/java/io/deephaven/util/thread/ThreadInitializationFactory.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.deephaven.util.thread; | ||
|
||
import io.deephaven.configuration.Configuration; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Extension point to allow threads that will run user code from within the platform to be controlled by configuration. | ||
*/ | ||
public interface ThreadInitializationFactory { | ||
/* private */ String[] CONFIGURED_INITIALIZATION_TYPES = | ||
Configuration.getInstance().getStringArrayFromProperty("thread.initialization"); | ||
/* private */ List<ThreadInitializationFactory> INITIALIZERS = Arrays.stream(CONFIGURED_INITIALIZATION_TYPES) | ||
.filter(str -> !str.isBlank()) | ||
.map(type -> { | ||
try { | ||
// noinspection unchecked | ||
Class<? extends ThreadInitializationFactory> clazz = | ||
(Class<? extends ThreadInitializationFactory>) Class.forName(type); | ||
return clazz.getDeclaredConstructor().newInstance(); | ||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | ||
| InstantiationException | IllegalAccessException e) { | ||
throw new IllegalArgumentException( | ||
"Error instantiating initializer " + type + ", please check configuration"); | ||
} | ||
}) | ||
.collect(Collectors.toUnmodifiableList()); | ||
|
||
/** | ||
* Chains configured initializers to run before/around any given runnable, returning a runnable intended to be run | ||
* by a new thread. | ||
*/ | ||
static Runnable wrapRunnable(Runnable runnable) { | ||
Runnable acc = runnable; | ||
for (ThreadInitializationFactory INITIALIZER : INITIALIZERS) { | ||
acc = INITIALIZER.createInitializer(acc); | ||
} | ||
return acc; | ||
} | ||
|
||
Runnable createInitializer(Runnable runnable); | ||
} |
This file contains 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
This file contains 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
This file contains 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
19 changes: 0 additions & 19 deletions
19
engine/table/src/main/java/io/deephaven/engine/util/DaemonThreadFactory.java
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.