MCPcopy Create free account
hub / github.com/benfry/processing4 / initAnimator

Method initAnimator

core/src/processing/opengl/PSurfaceJOGL.java:390–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

388
389
390 protected void initAnimator() {
391 if (PApplet.platform == PConstants.WINDOWS) {
392 // Force Windows to keep timer resolution high by creating a dummy
393 // thread that sleeps for a time that is not a multiple of 10 ms.
394 // See section titled "Clocks and Timers on Windows" in this post:
395 // https://web.archive.org/web/20160308031939/https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks
396 Thread highResTimerThread = new Thread(() -> {
397 try {
398 Thread.sleep(Long.MAX_VALUE);
399 } catch (InterruptedException ignore) { }
400 }, "HighResTimerThread");
401 highResTimerThread.setDaemon(true);
402 highResTimerThread.start();
403 }
404
405 animator = new FPSAnimator(window, 60);
406 animators.add(animator);
407
408 drawException = null;
409 animator.setUncaughtExceptionHandler((animator, drawable, cause) -> {
410 synchronized (drawExceptionMutex) {
411 drawException = cause;
412 drawExceptionMutex.notify();
413 }
414 });
415
416 drawExceptionHandler = new Thread(() -> {
417 synchronized (drawExceptionMutex) {
418 try {
419 while (drawException == null) {
420 drawExceptionMutex.wait();
421 }
422 Throwable cause = drawException.getCause();
423 if (cause instanceof RuntimeException) {
424 throw (RuntimeException) cause;
425 } else if (cause instanceof UnsatisfiedLinkError) {
426 throw new UnsatisfiedLinkError(cause.getMessage());
427 } else if (cause == null) {
428 throw new RuntimeException(drawException.getMessage());
429 } else {
430 throw new RuntimeException(cause);
431 }
432 } catch (InterruptedException ignored) { }
433 }
434 });
435 drawExceptionHandler.start();
436 }
437
438
439 @Override

Callers 1

initFrameMethod · 0.95

Calls 3

getMessageMethod · 0.65
startMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected