1. # Schedulers do this role. It mostly serves as an interface for the things
  2. # that schedulers must do, as well as a way to factor out some common "sugar"
  3. # and infrastructure.
  4. my role Scheduler {
  5. has &.uncaught_handler is rw;
  6. method handle_uncaught($exception) {
  7. my $ch = &!uncaught_handler;
  8. if $ch {
  9. $ch($exception);
  10. }
  11. else {
  12. # No default handler, so terminate the application.
  13. note "Unhandled exception in code scheduled on thread " ~ $*THREAD.id;
  14. if Rakudo::Internals.LL-EXCEPTION {
  15. note $exception.message;
  16. note $exception.backtrace.full;
  17. }
  18. else {
  19. note $exception.gist;
  20. }
  21. exit(1);
  22. }
  23. }
  24. method cue { ... }
  25. method loads() { ... }
  26. }