commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Curdt <tcu...@apache.org>
Subject Re: [javaflow] Knowing when there's nothing to continue
Date Thu, 28 Jul 2005 08:36:20 GMT
>
> 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


Mime
View raw message