Questions tagged [continuations]

In computer science and programming, a continuation is an abstract representation of the control state. A continuation reifies an instance of a computational process at a given point in the process's execution. It contains information such as the process's current stack (including all data whose lifetime is within the process e.g. "local variables"), as well the process's point in the computation.

Using continuation, when a function calls another function, that is the last thing it does. An extra argument is part of every function, which will be used to pass each function's continuation. Instead of waiting for the called function to return, it puts any work it wants to do afterwards into a continuation, which it passes to the function. Essentially, this involves breaking up the code into a collection of callback functions.

535 questions
0
votes
1 answer

Loadable program checkpoints in python (serializable continuations/program images)

Lets say I have a python program that does following: do_some_long_data_crunching_computation() call_some_fiddly_new_crashing_function() Is there a way to "freeze" and serialize the state of python program (all globals and such) after the return…
artemonster
  • 744
  • 4
  • 27
0
votes
0 answers

Boost future continuation doesn't get called

The continuation for a boost::future gets called when using boost::async but not under std::thread. I am using "gcc version 5.3.0 20151204 (Ubuntu 5.3.0-3ubuntu1~14.04)" In the following program, the code under the "WORKS" macro prints the…
SandeepJ
  • 341
  • 4
  • 10
0
votes
2 answers

Converting functions to CPS

I have the following CPS implementation of until: until' p f x cc = p x (\y -> if y then cc(x) else until' p f (f x (\z -> cc(z))) cc) Which type checks ok! Now, trying to CPS map: map' f (x:xs) cc = f x (\y -> map f xs…
cybertextron
  • 10,547
  • 28
  • 104
  • 208
0
votes
1 answer

executing ContinueWith when other continuations have not executed

Given something like this: .ContinueWith((_, o) => this.Foo(), null, TaskContinuationOptions.OnlyOnRanToCompletion) .ContinueWith((_, o) => this.Bar(), null, TaskContinuationOptions.OnlyOnFaulted) .ContinueWith((_, o) => this.AnythingElse(), null,…
Jim
  • 14,952
  • 15
  • 80
  • 167
0
votes
1 answer

Crash using Mono.Tasklets.Continuation

I'm attempting to work on a microthread message passing library in C# using mono. Since Mono 2.4 or so, apparently continuations (not yield) have been available under 'Mono.Tasklets'. However, these lack any documentation that I can find, and…
Nicholas M T Elliott
  • 3,643
  • 2
  • 19
  • 15
0
votes
1 answer

Trying to exercise with the Cont monad. Syntax issue

After some study ([1], [2], [3] among others) I am trying to make work of the continuation monad by attempting some examples on my own. The second answer to [1] suggests to express the factorial using continuations. My solution is the…
Marco Faustinelli
  • 3,734
  • 5
  • 30
  • 49
0
votes
2 answers

Task Continuation NullReferenceException

So I have a continuation defined: var task = _httpClient.SendAsync(request, cts.Token); task.ContinueWith(i => { /* TODO: log */ }, TaskContinuationOptions.OnlyOnCanceled); var response = await task.ConfigureAwait(false); I get a compiler…
Haney
  • 32,775
  • 8
  • 59
  • 68
0
votes
2 answers

sum of continuous values in matlab

I need to calculate the following in matlab. EDIT EDIT: I alway have a 16 x 3 matrix. 16 rows and 3 columns. The 3 columns represent R,G,B and the 16 rows represent points. From 1-16. An example matrix looks like this: 1 1 1 -1 0 0 0 0 1 1 0 0…
AngelsEnd
  • 43
  • 5
0
votes
1 answer

Multiple continuation chaining: boost.future unwrapping. How to do it

I am using boost.future with continuations, in boost 1.56. I have an API that returns a future, that I want to use from inside a continuation. So in theory, I need to .unwrap the future before chaining the second continuation. So I do the…
Germán Diago
  • 7,473
  • 1
  • 36
  • 59
0
votes
1 answer

Making continuation monad wrapper instance of Monad class

I have type Foo which is simple wrapper around Cont a a. I would like to make Foo type an instance of Monad class. I try this: import Control.Monad.Cont newtype Foo a = Foo {unFoo :: Cont a a} instance Monad Foo where return = Foo . return …
sergeyz
  • 1,308
  • 2
  • 14
  • 23
0
votes
1 answer

Explaining different behavior of variables referenced in continuations?

Following are two case which have different behaviors regarding the value of i across calls to stored continuations. How can the difference be explained? Case A >(define cc #f) >(define (x) (let ((i 0)) (set! i (+ i 100)) (+ i (+ i…
rex
  • 11
  • 2
0
votes
1 answer

Exception handling in ContinueWith called infinitely

I'm calling an async method (Specifically: Microsoft.ServiceBus.Messaging.QueueClient.SendAsync()) and want to be able to handle the exceptions within. One possibility I have come across is: _queueClient.SendAsync(message).ContinueWith((t) => { …
Henry Ing-Simmons
  • 1,362
  • 5
  • 18
  • 25
0
votes
0 answers

How do continuations work in complex applications, like a web server or GUI app?

I've always had a time understanding a particular aspect of continuations. I understand the basic concept - that you can invoke a continuation to transfer control to the place where you saved the continuation. For simple examples, like REPL…
Bill
  • 44,502
  • 24
  • 122
  • 213
0
votes
1 answer

asp.net mvc or javascript return results of another page to method

Is it possible to have results from another page returned to a JavaScript method or a C# controller action? I have a shared complex page that's used all over my website that's currently used to set a single variable on the user data in the C# back…
Giles Roberts
  • 6,407
  • 6
  • 48
  • 63
0
votes
1 answer

Detect client has disconnected from jetty server (using continuations)

I am using jetty continuations and I was wondering if I can detect that the client has disconnected(closed connection to jetty server) from the server. Thanks, Alfred
Alfred
  • 60,935
  • 33
  • 147
  • 186
1 2 3
35
36