I want a serializable continuation so I can pickle async workflows to disk while waiting for new events. When the async workflow is waiting on a let!, it would be saved away along with a record of what was needed to wake it up. Instead of arbitrary in-memory IAsyncResults (or Task<T>, etc.), it would have to be, for instance, a filter criterion for incoming messages along with the continuation itself. Without language support for continuations, this might be a feat. But with computation expressions taking care of the explicit CPS tranformation, it might not be too tricky and could even be more efficient. Has anyone tackled an approach like this?
I want a serializable continuation so I can pickle async workflows to disk while
Share
You could probably use the
MailboxProcessor, orAgent, type as a means of getting close to what you want. You’d could then use theagent.PostAndAsyncReplywith a timeout to retrieve the currentAgentState. As mentioned above, you’ll need to make the objects you are passing around serializable, but even delegates are serializable. The internals are really unrelated toasynccomputations, though. Theasynccomputation would merely allow you a way to interact with the various agents in your program in a non-blocking fashion.Dave Thomas and I have been working on a library called fracture-io that will provide some out-of-the-box scenarios for working with agents. We hadn’t yet discussed this exact scenario, but we could probably look at baking this in … or take a commit. 🙂
I also noticed that you tagged your question with
callcc. I posted a sample of that operator to fssnip, but Tomas Petricek quickly posted an example of how easy it is to break withasynccomputations. So I don’t thinkcallccis a useful solution for this question. If you don’t needasync, you can look in FSharpx for theContinuationmodule and thecallccoperator in there.