-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Run isolated tasks last #4004
Run isolated tasks last #4004
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import static java.util.concurrent.CompletableFuture.completedFuture; | ||
import static org.apiguardian.api.API.Status.STABLE; | ||
import static org.junit.platform.engine.support.hierarchical.Node.ExecutionMode.CONCURRENT; | ||
import static org.junit.platform.engine.support.hierarchical.Node.ExecutionMode.SAME_THREAD; | ||
|
||
import java.lang.Thread.UncaughtExceptionHandler; | ||
import java.lang.reflect.Constructor; | ||
|
@@ -38,6 +39,7 @@ | |
import org.junit.platform.commons.logging.LoggerFactory; | ||
import org.junit.platform.commons.util.ExceptionUtils; | ||
import org.junit.platform.engine.ConfigurationParameters; | ||
import org.junit.platform.engine.support.hierarchical.SingleLock.GlobalReadWriteLock; | ||
|
||
/** | ||
* A {@link ForkJoinPool}-based | ||
|
@@ -155,29 +157,34 @@ public void invokeAll(List<? extends TestTask> tasks) { | |
new ExclusiveTask(tasks.get(0)).execSync(); | ||
return; | ||
} | ||
Deque<ExclusiveTask> nonConcurrentTasks = new LinkedList<>(); | ||
Deque<ExclusiveTask> isolatedTasks = new LinkedList<>(); | ||
Deque<ExclusiveTask> sameThreadTasks = new LinkedList<>(); | ||
Comment on lines
+160
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 why are we using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering that, too, but kept using |
||
Deque<ExclusiveTask> concurrentTasksInReverseOrder = new LinkedList<>(); | ||
forkConcurrentTasks(tasks, nonConcurrentTasks, concurrentTasksInReverseOrder); | ||
executeNonConcurrentTasks(nonConcurrentTasks); | ||
forkConcurrentTasks(tasks, isolatedTasks, sameThreadTasks, concurrentTasksInReverseOrder); | ||
executeSync(sameThreadTasks); | ||
joinConcurrentTasksInReverseOrderToEnableWorkStealing(concurrentTasksInReverseOrder); | ||
executeSync(isolatedTasks); | ||
} | ||
|
||
private void forkConcurrentTasks(List<? extends TestTask> tasks, Deque<ExclusiveTask> nonConcurrentTasks, | ||
Deque<ExclusiveTask> concurrentTasksInReverseOrder) { | ||
private void forkConcurrentTasks(List<? extends TestTask> tasks, Deque<ExclusiveTask> isolatedTasks, | ||
Deque<ExclusiveTask> sameThreadTasks, Deque<ExclusiveTask> concurrentTasksInReverseOrder) { | ||
for (TestTask testTask : tasks) { | ||
ExclusiveTask exclusiveTask = new ExclusiveTask(testTask); | ||
if (testTask.getExecutionMode() == CONCURRENT) { | ||
exclusiveTask.fork(); | ||
concurrentTasksInReverseOrder.addFirst(exclusiveTask); | ||
if (testTask.getResourceLock() instanceof GlobalReadWriteLock) { | ||
isolatedTasks.add(exclusiveTask); | ||
} | ||
else if (testTask.getExecutionMode() == SAME_THREAD) { | ||
sameThreadTasks.add(exclusiveTask); | ||
} | ||
else { | ||
nonConcurrentTasks.add(exclusiveTask); | ||
exclusiveTask.fork(); | ||
concurrentTasksInReverseOrder.addFirst(exclusiveTask); | ||
} | ||
} | ||
} | ||
|
||
private void executeNonConcurrentTasks(Deque<ExclusiveTask> nonConcurrentTasks) { | ||
for (ExclusiveTask task : nonConcurrentTasks) { | ||
private void executeSync(Deque<ExclusiveTask> tasks) { | ||
marcphilipp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (ExclusiveTask task : tasks) { | ||
task.execSync(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 The only thing that is a bit weird is that isolated tasks can only be top-level tasks, yet this is invoked on multiple levels. Probably not worth changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have a different class for the top-level task and other tasks. 🤔