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. note $exception.gist;
  15. exit(1);
  16. }
  17. }
  18. method cue { ... }
  19. method loads() { ... }
  20. }