mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1014338 - Pre: add ThreadUtils.assertNotOnUiThread. r=margaret
This commit is contained in:
parent
f34ef75ba6
commit
d44b0faec2
@ -120,6 +120,10 @@ public final class ThreadUtils {
|
||||
assertOnThread(getUiThread(), AssertBehavior.THROW);
|
||||
}
|
||||
|
||||
public static void assertNotOnUiThread() {
|
||||
assertNotOnThread(getUiThread(), AssertBehavior.THROW);
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public static void assertOnGeckoThread() {
|
||||
assertOnThread(sGeckoThread, AssertBehavior.THROW);
|
||||
@ -134,11 +138,19 @@ public final class ThreadUtils {
|
||||
}
|
||||
|
||||
public static void assertOnThread(final Thread expectedThread, AssertBehavior behavior) {
|
||||
assertOnThreadComparison(expectedThread, behavior, true);
|
||||
}
|
||||
|
||||
public static void assertNotOnThread(final Thread expectedThread, AssertBehavior behavior) {
|
||||
assertOnThreadComparison(expectedThread, behavior, false);
|
||||
}
|
||||
|
||||
private static void assertOnThreadComparison(final Thread expectedThread, AssertBehavior behavior, boolean expected) {
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
final long currentThreadId = currentThread.getId();
|
||||
final long expectedThreadId = expectedThread.getId();
|
||||
|
||||
if (currentThreadId == expectedThreadId) {
|
||||
if ((currentThreadId == expectedThreadId) == expected) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user