[javaflow] Continuation.startSuspendedWith(Runnable)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[javaflow] Continuation.startSuspendedWith(Runnable)

Kohsuke Kawaguchi

Torsten,

While implementing the workflow engine, I found that it's convenient to
be able to create a Continuation without actually executing it. This is
analogous to creating a thread in a suspended state.

While this can be easily emulated by wrapping the Runnable into the
following Runnable,

        new Runnable() {
                public void run() {
                        Continuation.suspend();
                        realTarget.run();
                }
        }

it's bit convenient and faster/easier to do so in the javaflow itself,
because all I need to do is:

         return new Continuation(new StackRecorder(target));

In Win32 thread API one can create a thread in a suspended state, so at
some people seem to find that this is a generally useful feature. OTOH,
POSIX thread API doesn't have the equivalent AFAIK, nor
java.lang.Thread. So I'm not quite sure if this code should live in
javaflow or I should keep it on my side.

So I don't feel strongly either way, but if you are OK with putting this
change into javaflow, just because it's easier than the other approach.

--
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [javaflow] Continuation.startSuspendedWith(Runnable)

Torsten Curdt

On 13.08.2005, at 23:47, Kohsuke Kawaguchi wrote:

>
> Torsten,
>
> While implementing the workflow engine, I found that it's  
> convenient to be able to create a Continuation without actually  
> executing it. This is analogous to creating a thread in a suspended  
> state.
>
> While this can be easily emulated by wrapping the Runnable into the  
> following Runnable,
>
>     new Runnable() {
>         public void run() {
>             Continuation.suspend();
>             realTarget.run();
>         }
>     }
>
> it's bit convenient and faster/easier to do so in the javaflow  
> itself, because all I need to do is:
>
>         return new Continuation(new StackRecorder(target));
This definitely looks nicer.
But I am not sure. :-/

...can you please send me the diff
off-list?

cheers
--
Torsten


PGP.sig (193 bytes) Download Attachment