Thank you for a quick response and listening to my suggestion.
Torsten Curdt wrote:
..but how about the other way around. We could
also provide
Continuation startWith(ContinuationContext) // means: use method "run"
Continuation startWith(String, ContinuationContext)
with a standard ContinuationContext that explicitly
supports a Runnable by providing a default implementation.
So a bit simplified you could do:
startWith(new DefaultContinuationContext(Runnable))
That would give us all the flexibility and the simplified
interface
WDYT?
If I understand this correctly, for me to capture the continuation and
run it later, I do:
Runnable myRunnable = new MyRunnable(...);
Continuation c = Continuation.startWith(
new DefaultContinuationContext(myRunnable))
// serialize the continuation
ObjectOutputStream oos = ...;
oos.writeObject(c);
oos.writeObject(myRunnable);
/* later */
ObjectInputStream ois = ...;
Continuation c = ois.readObject();
Runnable myRunnable = ois.readObject();
c.continueWith(new DefaultContinuationContext(myRunnable));
is that correct? (I'm assuming that you designed ContinuationContext to
keep track of things you want to change between runs, so it's not
reachable from Continuation if it's not executing.)
I thought it would be nice if I can write it instead as:
Runnable myRunnable = new MyRunnable(...);
Continuation c = Continuation.startWith(myRunnable,null);
// serialize the continuation
ObjectOutputStream oos = ...;
oos.writeObject(c);
/* later */
ObjectInputStream ois = ...;
Continuation c = ois.readObject();
c.continueWith(null);
Or maybe what I really wanted was to the "ContinuableThread" class or
something that wraps the existing API into a class that feels like
java.lang.Thread, so that I can do:
ContinuableThread t = new ContinuableThread() {
// override run or pass in Runnable to the constructor
void run() { ...; suspend(); ...; }
}
t.start(); // start running. return when suspended
oos.writeObject(t); // serialize
t = ois.readObject(); // deserialize
t = t.clone(); // AKA thread fork
while(t.isAlive())
t.continue();
If I wanted to do the equivalent of the ContinuationContext, I can
define a field in my derived class and set if every time before I call
continue.
I can implement this on top of existing javaflow code without changing
them. Does this work with you?
--
Kohsuke Kawaguchi
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]