<div dir="ltr">It&#39;s great that Linux already has something to rely on, but there is a subtle difference. In the case you mentioned, as far as I understand, pthread_cancel will ask the thread to cancel, and this will be possible only when we reach the Cancelation point, this mechanism is much better than a stop token, but very similar to it. In case of RAII thread we can interrupt the execution thread immediately without waiting for Cancelation point or token check, except for a few intervals like prologue and epilogue, destructor (destructors need to be discussed in detail), etc., where special handling is needed.<br>In case of pthread there are points at which we cancel the thread, in case of RAII thread there are certain intervals at which we can/can&#39;t destroy it. The gist of this idea is that if the thread corresponds to RAII as a whole, it is not necessary to wait for Cancellation point. In general, I would really like to use the handler mechanism you mentioned. I&#39;ll be sure to add the relevant part to the discussion, thank you.<br></div>

