struct thread_interrupted

Declaration

struct thread_interrupted : public std::exception { /* full declaration omitted */ };

Description

A pika::thread_interrupted is the exception type used by pika to interrupt a running pika thread.

//////////////////////////////////////////////////////////////////////// The \atype is the exception type used by pika to interrupt a running thread. A running thread can be interrupted by invoking the interrupt() member function of the corresponding pika::thread object. When the interrupted thread next executes one of the specified interruption points (or if it is currently blocked whilst executing one) with interruption enabled, then a pika::thread_interrupted exception will be thrown in the interrupted thread. If not caught, this will cause the execution of the interrupted thread to terminate. As with any other exception, the stack will be unwound, and destructors for objects of automatic storage duration will be executed. If a thread wishes to avoid being interrupted, it can create an instance of \aObjects of this class disable interruption for the thread that created them on construction, and restore the interruption state to whatever it was before on destruction. The effects of an instance of \acan be temporarily reversed by constructing an instance of\apassing in the\aobject in question. This will restore the interruption state to what it was when the\aobject was constructed, and then disable interruption again when the\aobject is destroyed. At any point, the interruption state for the current thread can be queried by calling \a

Declared at: libs/pika/errors/include/pika/errors/exception.hpp:182

Inherits from: std::exception