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
1
vote
1 answer

Continuation with Tasks (instead of delegates)

I have a class where each method execute asynchronously, i.e. return a Task, but where each method should nevertheless wait for the completion of the preceding call. Continuation, right? Except that a task continuation takes a delegate (Action) in…
1
vote
1 answer

Efficient resource usage in TPL continuations

I'm interested in efficiently using system resources in conjunction with the Task Parallel Library and continuations. Consider the following scenario which uses the GetResponseAsync() extension method defined in another recent question. WebRequest…
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
1
vote
2 answers

Using async/await, when do continuations happen?

I am attempting to use async/await in a very large already existing synchronous code base. There is some global state in this code base that works fine, if kludgy, in a synchronous context, but it doesn't work in the asynchronous context of…
Ashley
  • 471
  • 7
  • 15
1
vote
2 answers

akka dataflow and side effects

I'm working with akka dataflow and I'd like to know if there is a way to cause a particular block of code to wait for the completion of a future, without explicitly using the value of that future. The actual use case is that I have a file and I want…
Dave DeCaprio
  • 2,051
  • 17
  • 31
1
vote
0 answers

making sure Android app operates as expected when when user leaves GUI and comes back

I have written an Android app that plays audio file. On the GUI I have a STOP button that when pressed stops playing of the audio. If I stay in the app GUI I can stop and start as many time as I want and everything works fine. However, if I start…
TJ1
  • 7,578
  • 19
  • 76
  • 119
1
vote
1 answer

Continuation in Scheme with lambda with no arguments

So I am dealing with continuations and have something like this: (or (call/cc (lambda (cont) ... (if ( ... ) (cons randomList (lambda() (cont #f))) #f)})} ( do something else) I was…
bph
  • 189
  • 2
  • 14
1
vote
1 answer

Mono Continuations - Memory keeps increasing after store()

Here's Mono Continuations' continuation_store (...). From looking at the code below, it appears as though store() follows these two branches: cont->saved_stack && num_bytes <= cont->stack_alloc_size use the memory directly else gc free the…
jameszhao00
  • 7,213
  • 15
  • 62
  • 112
1
vote
2 answers

Which is the current continuation in the following expression?

In the expression (call/cc (lambda (k) (k 12))), there are three continuations: (k 12), (lambda (k) (k 12)), and (call/cc (lambda (k) (k 12))). Which one is the "current continuation"? And continuations in some books are viewed as a procedure which…
1
vote
3 answers

Methods for side-effects in purely functional programming languages

At the moment I'm aware of the following methods to integrate side-effects into purely functional programming languages: effect systems continuations unique types monads Monads are often cited to be the most effective and most general way to do…
user141335
1
vote
0 answers

Unhandled AggregateException on Tasks Continuation thrown on another OS

I'm getting a strange behavior in a winForms application while testing to see how it responds on different OS. The long running operation where the unhandled AggregateException is thrown ( when tested on a XP 32bit machine) is part of a WCF (using…
Pantelis
  • 2,060
  • 3
  • 25
  • 40
1
vote
2 answers

chaining array of tasks with continuation

I have a Task structure that is a little bit complex(for me at least). The structure is: (where T = Task) T1, T2, T3... Tn. There's an array (a list of files), and the T's represent tasks created for each file. Each T has always two subtasks that it…
Amc_rtty
  • 3,662
  • 11
  • 48
  • 73
1
vote
1 answer

Detecting When a Tree of Threads Completed

I am creating a simple web spider. All it does is accept a URL, download the HTML and extract the remaining URLs. It then repeats the process for each new URL. I'm also making sure I don't visit the same URL twice and I am limiting the number of…
Travis Parks
  • 8,435
  • 12
  • 52
  • 85
1
vote
4 answers

C++ force stack unwinding inside function

I'm in the process of learning C++ and currently I'm fiddling with the following code: class Bar; struct Callback { virtual void Continue(Bar&) = 0; }; // ... void Foo(Bar& _x, Callback& result) { // Do stuff with _x if(/* some…
Pindatjuh
  • 10,550
  • 1
  • 41
  • 68
0
votes
2 answers

How to read fixed size of bytes turn by turn in continuation using Ruby?

I have one binary file and I want to read this file like first four bytes then next 5 bytes then next 3 bytes till file ends. I am able to read file using each_byte but I want to categorize all these bytes in groups in sequence they are stored in…
Akash Panchal
  • 205
  • 1
  • 6
  • 20
0
votes
2 answers

Simple Async operation with Continuation scenario doesn't work on a WPF app

I have a really simple operation on a WPF app in order to try out async operations. Here is my complete code: static int GetPrimes() { var query = from n in Enumerable.Range(3, 5000000).AsParallel() where Enumerable.Range(2,…
tugberk
  • 57,477
  • 67
  • 243
  • 335