Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The lack of safety comes from the idea idea of critical sections</p> <pre><code>Take mutex do some work, temporarily while we work our state is inconsistent // all consistent now Release mutex </code></pre> <p>If you blow away the thread and it happend to be in a critical section then the object is left in an inconsistent state, that means not safely usable from that point.</p> <p>For it to be safe to kill the thread you need to understand the entire processing of whatever is being done in that thread, to know that there are no such critical sections in the code. If you are using library code, then you may not be able to see the source and know that it's safe. Even if it's safe today it may not be tomorrow.</p> <p>(Very contrived) Example of possible unsafety. We have a linked list, it's not cyclic. All the algorithms are really zippy because we <strong>know</strong> it's not cyclic. During our critical section we temporarily introduce a cycle. We then get blown away before we emerge from the critical section. Now all the algorithms using the list loop forever. No library author would do that surely! How do you know? You cannot assume that code you use is well written.</p> <p>In the example you point to, it's surely possible to write the requreid functionality in an interruptable way. More work, but possible to be safe.</p> <p>I'll take a flyer: there is no documented subset of Objects and methods that can be used in cancellable threads, because no library author wants to make the guarantees. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload