You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Kohsuke Kawaguchi <kk...@kohsuke.org> on 2005/07/28 02:10:12 UTC

[javaflow] Knowing when there's nothing to continue

It looks like the other discussion is going to take longer, so meanwhile 
I have a few other simple changes.

- Continuation.getContext() is typed as Object while it can be
   ContinuationContext. I think using a stricter type is desirable, hence
   the change.

- minor javadoc elaboration on the semantics of getContext().
   This is a developer visible 'API' from this method, so it needs better
   javadoc.
   I have a feeling that you might not like it, but I think I need to
   learn your taste by a trial & error process. So bare with me for a
   while...

- Lastly, right now the continueWith method always return a non-null
   Continuation object, even if there's actually nothing to continue.
   Using such a Continuation object next time around causes an error.
   This isn't good. I think the caller needs to be able to tell if the
   continueWith method returned because the "thread" has suspended, or
   because the "thread" has completed.
   I modified the execute method to return null if the latter.

Let me know which change you are OK with and which change you aren't. 
I'll commit accordingly.

-- 
Kohsuke Kawaguchi

Re: [javaflow] Knowing when there's nothing to continue

Posted by Kohsuke Kawaguchi <kk...@kohsuke.org>.
Torsten Curdt wrote:
>>
>> It looks like the other discussion is going to take longer, so  
>> meanwhile I have a few other simple changes.
> 
> Hehe ...bring it on ;)
> 
> Did you have a look into the Cocoon integration?
> Looking at javaflow from that standpoint you will
> probably understand some of my requirements.

I intend to do so, before I write a response on the MethodLookup thread. 
But I couldn't work on it yesterday. This isn'y my day job, unfortunately.

>>      /**
>> -     * get the current contex. only valid
> 
> The method is already called "getContext"
> ("get the current context" ;) ...so IMO all
> we need to explain is *what* this context is
> and what is so special about it.
> 
> In fact most of that information should
> be given inside ContinuationContext.java
> and we could link to it from here.
> 
> So in the end information that I think is
> important is as you state later on ...it's
> the same context object that is being passed
> in with start/continue.
> 
> IMHO that's it.
> 
> Don't want to be too picky ...but just tried
> to explain how I see that javadoc thingy ;)

I appreciate it. I think I'll remove the part that talks about the point 
of context and then you are OK with it.

> Please always use { } for if/else

I will do that.



-- 
Kohsuke Kawaguchi

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [javaflow] Knowing when there's nothing to continue

Posted by Torsten Curdt <tc...@apache.org>.
>
> It looks like the other discussion is going to take longer, so  
> meanwhile I have a few other simple changes.

Hehe ...bring it on ;)

Did you have a look into the Cocoon integration?
Looking at javaflow from that standpoint you will
probably understand some of my requirements.

> - Continuation.getContext() is typed as Object while it can be
>   ContinuationContext. I think using a stricter type is desirable,  
> hence
>   the change.

Ok

> - minor javadoc elaboration on the semantics of getContext().
>   This is a developer visible 'API' from this method, so it needs  
> better
>   javadoc.
>   I have a feeling that you might not like it, but I think I need to
>   learn your taste by a trial & error process. So bare with me for a
>   while...

Don't worry ;)

> - Lastly, right now the continueWith method always return a non-null
>   Continuation object, even if there's actually nothing to continue.
>   Using such a Continuation object next time around causes an error.
>   This isn't good. I think the caller needs to be able to tell if the
>   continueWith method returned because the "thread" has suspended, or
>   because the "thread" has completed.
>   I modified the execute method to return null if the latter.

Ok

>      /**
> -     * get the current contex. only valid

The method is already called "getContext"
("get the current context" ;) ...so IMO all
we need to explain is *what* this context is
and what is so special about it.

In fact most of that information should
be given inside ContinuationContext.java
and we could link to it from here.

So in the end information that I think is
important is as you state later on ...it's
the same context object that is being passed
in with start/continue.

IMHO that's it.

Don't want to be too picky ...but just tried
to explain how I see that javadoc thingy ;)

> -     * while calling "continueWith"
> -     *
> -     * @return context object
> +     * get the current context.
> +     *
> +     * <p>
> +     * This method returns the same context object given to {@link  
> #startWith(String, ContinuationContext)}
> +     * or {@link #continueWith(Continuation, ContinuationContext)}.
> +     * This mechanism allows applications to associate application- 
> specific information to
> +     * a fiber.
> +     *
> +     * @return
> +     *      null if this method is invoked outside {@link  
> #startWith(String, ContinuationContext)}
> +     *      or {@link #continueWith(Continuation,  
> ContinuationContext)} .
>       */
> -    public Object getContext() {
> +    public ContinuationContext getContext() {
>          return context;
>      }
>
> @@ -109,6 +116,7 @@
>      }
>
>      private static Continuation execute(final Continuation  
> continuation, final ContinuationContext context) {
> +        boolean completed = false;
>          try {
>              continuation.registerThread();
>
> @@ -144,6 +152,8 @@
>                  if (continuation.stack.hasReference()) {
>                      continuation.stack.popReference();
>                  }
> +            } else {
> +                completed = true;
>              }
>
>              continuation.context = null;
> @@ -151,7 +161,8 @@
>              continuation.deregisterThread();
>          }
>
> -        return continuation;
> +        if(completed)   return null;
> +        else            return continuation;

Please always use { } for if/else

Thanks a lot for your help!

cheers
--
Torsten