MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / mainEDTLoop

Method mainEDTLoop

CodenameOne/src/com/codename1/ui/Display.java:1048–1150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1046 /// prevent blocking of actual input and drawing operations. This also
1047 /// enables functionality such as "true" modal dialogs etc...
1048 void mainEDTLoop() {
1049 impl.initEDT();
1050 UIManager.getInstance();
1051 try {
1052 // when there is no current form the EDT is useful only
1053 // for features such as call serially
1054 while (impl.getCurrentForm() == null) { // PMD Fix: AvoidBranchingStatementAsLastInLoop
1055 synchronized (lock) {
1056 while (shouldEDTSleep() && pendingIdleSerialCalls.isEmpty()) {
1057 try {
1058 lock.wait();
1059 } catch (InterruptedException ie) {
1060 Thread.currentThread().interrupt();
1061 break;
1062 }
1063 }
1064 if (shouldEDTSleep() && !pendingIdleSerialCalls.isEmpty()) {
1065 Runnable r = pendingIdleSerialCalls.remove(0);
1066 callSerially(r);
1067 }
1068
1069 // paint transition or intro animations and don't do anything else if such
1070 // animations are in progress...
1071 if (animationQueue != null && !animationQueue.isEmpty()) {
1072 paintTransitionAnimation();
1073 continue;
1074 }
1075 }
1076 processSerialCalls();
1077 }
1078 } catch (Throwable err) {
1079 Log.e(err);
1080 if (crashReporter != null) {
1081 crashReporter.exception(err);
1082 }
1083 if (!impl.handleEDTException(err)) {
1084 if (errorHandler != null) {
1085 errorHandler.fireActionEvent(new ActionEvent(err, ActionEvent.Type.Exception));
1086 } else {
1087 Dialog.show("Error", "An internal application error occurred: " + err, "OK", null);
1088 }
1089 }
1090 }
1091
1092 while (codenameOneRunning) { // PMD Fix: AvoidBranchingStatementAsLastInLoop
1093 try {
1094 // wait indefinetly Lock surrounds the should method to prevent serial calls from
1095 // getting "lost"
1096 synchronized (lock) {
1097 if (shouldEDTSleep()) {
1098 if (!pendingIdleSerialCalls.isEmpty()) {
1099 Runnable r = pendingIdleSerialCalls.remove(0);
1100 callSerially(r);
1101 } else {
1102 impl.edtIdle(true);
1103 while (shouldEDTSleep() && pendingIdleSerialCalls.isEmpty()) {
1104 try {
1105 lock.wait();

Callers 1

runMethod · 0.80

Calls 15

getInstanceMethod · 0.95
shouldEDTSleepMethod · 0.95
currentThreadMethod · 0.95
callSeriallyMethod · 0.95
processSerialCallsMethod · 0.95
eMethod · 0.95
showMethod · 0.95
edtLoopImplMethod · 0.95
handleExceptionMethod · 0.95
handleEDTExceptionMethod · 0.80
isEmptyMethod · 0.65

Tested by

no test coverage detected