Skip to content

Commit ede8e21

Browse files
coeuvrecopybara-github
authored andcommitted
Internal change.
PiperOrigin-RevId: 839712200 Change-Id: I15c9f36b73ea7872d6b32fbe1801b4b492fe5c4e
1 parent 3875b78 commit ede8e21

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main/java/com/google/devtools/build/lib/concurrent/TaskGroup.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ private static ThreadFactory defaultThreadFactory() {
9999
return Thread.ofVirtual().factory();
100100
}
101101

102+
/** Similar to {@link #open(ThreadFactory, Policy, Joiner)}, but uses a default thread factory. */
103+
public static <T, R> TaskGroup<T, R> open(
104+
Policy<? super T> policy, Joiner<? super T, ? extends R> joiner) {
105+
return new TaskGroup<>(defaultThreadFactory(), policy, joiner);
106+
}
107+
102108
/**
103109
* Opens a new task group with the given policy and joiner. It should be used with
104110
* try-with-resources statement like:
@@ -111,10 +117,15 @@ private static ThreadFactory defaultThreadFactory() {
111117
*
112118
* <p>The calling thread becomes the task group's owner and is the only thread allowed to call
113119
* {@link #fork}, {@link #join} or {@link #close} on it.
120+
*
121+
* <p>A new thread is created using the given {@code threadFactory} for each subtask. If the
122+
* factory returns {@code null}, a {@link RejectedExecutionException} is thrown.
114123
*/
115124
public static <T, R> TaskGroup<T, R> open(
116-
Policy<? super T> policy, Joiner<? super T, ? extends R> joiner) {
117-
return new TaskGroup<>(defaultThreadFactory(), policy, joiner);
125+
ThreadFactory threadFactory,
126+
Policy<? super T> policy,
127+
Joiner<? super T, ? extends R> joiner) {
128+
return new TaskGroup<>(threadFactory, policy, joiner);
118129
}
119130

120131
/**

0 commit comments

Comments
 (0)