MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / inMainThread

Method inMainThread

src/main/java/field/app/ThreadSync.java:452–473  ·  view source on GitHub ↗
(Runnable o)

Source from the content-addressed store, hash-verified

450 }
451
452 public static void inMainThread(Runnable o) throws InterruptedException, ExecutionException {
453 if (!enabled || fiber.get() == null)
454 o.run();
455 else {
456 CompletableFuture<Boolean> c = new CompletableFuture<>();
457 RunLoop.main.once(() -> {
458 try {
459 o.run();
460 c.complete(true);
461 } catch (Throwable t) {
462 t.printStackTrace();
463 c.cancel(true);
464 }
465 });
466 while (!c.isDone()) {
467 ThreadSync.yield(0);
468 }
469 if (c.isCompletedExceptionally()) {
470 c.get();
471 }
472 }
473 }
474
475 public static class Stop extends RuntimeException {
476

Callers 2

asMap_setMethod · 0.95
doEvalMethod · 0.45

Calls 5

yieldMethod · 0.95
onceMethod · 0.80
getMethod · 0.65
runMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected