forked from ppy/osu-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure to always reset execution mode
- Loading branch information
Showing
1 changed file
with
19 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
Check failure on line 4 in osu.Framework/Testing/HeadlessThreadRunner.cs GitHub Actions / Code Quality
|
||
using osu.Framework.Development; | ||
using osu.Framework.Platform; | ||
using osu.Framework.Threading; | ||
|
@@ -27,25 +28,30 @@ public override void RunMainLoop() | |
// Run a simulated multi-threaded mode. | ||
// This is because the CI test runners are usually CPU-limited and may be preferring one thread (audio) over another (update). | ||
|
||
ThreadSafety.ExecutionMode = ExecutionMode.SingleThread; | ||
|
||
for (int i = 0; i < Threads.Count; i++) | ||
try | ||
{ | ||
int from; | ||
int to; | ||
ThreadSafety.ExecutionMode = ExecutionMode.SingleThread; | ||
|
||
do | ||
for (int i = 0; i < Threads.Count; i++) | ||
{ | ||
from = RNG.Next(Threads.Count); | ||
to = RNG.Next(Threads.Count); | ||
} while (from == to); | ||
int from; | ||
int to; | ||
|
||
(Threads[from], Threads[to]) = (Threads[to], Threads[from]); | ||
} | ||
do | ||
{ | ||
from = RNG.Next(Threads.Count); | ||
to = RNG.Next(Threads.Count); | ||
} while (from == to); | ||
|
||
base.RunMainLoop(); | ||
(Threads[from], Threads[to]) = (Threads[to], Threads[from]); | ||
} | ||
|
||
ThreadSafety.ExecutionMode = ExecutionMode.MultiThreaded; | ||
base.RunMainLoop(); | ||
} | ||
finally | ||
{ | ||
ThreadSafety.ExecutionMode = ExecutionMode.MultiThreaded; | ||
} | ||
} | ||
} | ||
} |