// Try cancelling a thread. #include #include exception internal_error {}; vtable(internal_error) internal_vt; thread WillCancel {}; const char * msg(ThreadCancelled(WillCancel) * this) { return "ThreadCancelled(WillCancel)"; } void main(WillCancel &) { sout | '1'; cancel_stack((internal_error){&internal_vt}); sout | '!'; } void explicit() { try { sout | '0'; WillCancel cancel; sout | '1'; join(cancel); sout | '4'; } catchResume (ThreadCancelled(WillCancel) * error) { sout | '2'; if ((virtual internal_error *)error->the_exception) { sout | '3'; } } sout | '5' | nl; } void implicit() { try { { sout | '0'; WillCancel cancel; sout | '1'; } sout | '4'; } catchResume (ThreadCancelled(WillCancel) * error) { sout | '2'; if ((virtual internal_error *)error->the_exception) { sout | '3'; } } sout | '5' | nl; } int main(int argc, char * argv[]) { sout | nlOff; explicit(); implicit(); }