Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>A trivial example of using continuation</strong> would be implementing a thread (fiber if you wish) manager on a single-processor machine. The scheduler would interrupt the execution flow periodically (or, in the case of fibers, be invoked at various strategic points in the code), save the <em>continuation state</em> (corresponding to the <em>current thread</em>), then switch to a different <em>continuation state</em> (corresponding to a different thread whose state was saved previously.)</p> <p>Referring to your assembly background, <strong>the continuation state would capture such details as instruction pointer, registers, and stack context (pointer)</strong>, to be saved and restored at will.</p> <p>Another way of using continuation would be to <strong>think of replacing method calls with several thread-like entities</strong> that co-exist in parallel (either running or suspended) passing control to each other using continuation contexts instead of the 'classic' <code>call</code> paradigm. They would operate on global (shared) data instead of relying on parameters. This is to some extent more flexible than <code>call</code> in the sense that stack does not have to wind up then down (<code>calls</code> are <em>nested</em>), but control can pass around arbitrarily.</p> <p><strong>Attempting to visualize this concept</strong> in a language such a C, imagine having one big loop with a single <code>switch(continuation_point) { case point1: ... }</code> statement, where each <code>case</code> corresponds to a continuation-savepoint, and where the code inside each <code>case</code> can alter the value of <code>continuation_point</code> and relinquish control to that <code>continuation_point</code> by <code>break</code>ing from the <code>switch</code> and engaging the next iteration in the loop.</p> <p>What is the context of your question? Any particular scenarios you are interested in? Any particular programming language? Is the thread/fibre example above sufficient?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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