>
>
> Do not put code at //1 or //2 Did my example show that? I don't think it
> did. //1 and //2 should be inside the SM. Did you code an implementation or
> just do a desk check?
>

The whole point of syncing a series of async calls is to make the flow of
execution deterministic. I put print statements there just to show the
execution order. The execution order desired is:
// 1
async calls
// 2
return
That's the objective I want to achieve and no offence, I don't think that's
what your implementation does.


I sent you my gmail address.

>
> The dictionary entries are downloaded one at a time. The UI isn't live
> until all downloads complete. Either way, it looks like I've failed to
> communicate how this works. If you want to see a live demo, feel free to
> send an OpenID, I'll add it to to the authorization and you can watch it
> using FF and Firebug.
>
>
>
>> I think I need to clarify/reiterate what I need: I have a list of async
>> commands, and I want execute() method to execute these commands, either in
>> serial or parallel, and execute() method waits until all these commands
>> finish and then returns.
>>
>>
>>
>> On Thu, Aug 12, 2010 at 6:24 PM, Jeff Chimene <jchim...@gmail.com> wrote:
>>
>>> On 08/12/2010 02:23 PM, Kevin Qiu wrote:
>>> > Thanks for taking the time. Although it's not clear what action you put
>>> > in the timer and what the timer is supposed to do
>>>
>>> It's a "processing occurring" timer. I think I mentioned it earlier, so
>>> I didn't remove it from the example.
>>>
>>> > (IncrementalCommand is executed by DeferredCommand.CommandExecutor
>>> > and it already has a timer with timeslice set to 100ms).
>>>
>>> Right.
>>>
>>> > Also, I suppose you need to reset the "busy" flag in the callback of
>>> > the asynchronous calls.
>>>
>>> Yes. You already had that bit sussed. The case statement asynchronously
>>> drains the command queue, while providing a structure that synchronously
>>> resolves to a "final" command step.
>>>
>>> > I'm still a bit incredulous but I'll give it a try. Thanks again :)
>>>
>>> Feel free to ask.
>>>
>>> >
>>> > Cheers,
>>> >
>>> > On Thu, Aug 12, 2010 at 4:43 PM, Jeff Chimene <jchim...@gmail.com
>>> > <mailto:jchim...@gmail.com>> wrote:
>>> >
>>> >     On 08/12/2010 12:50 PM, Kevin Qiu wrote:
>>> >     > After some thought, I don't think putting it in
>>> IncrementalCommand and
>>> >     > execute with DeferredCommand help much here. Jeff, If I
>>> understand you
>>> >     > correctly, my execute method will look like this:
>>> >     >
>>> >     > class Executor {
>>> >     >   // declaration of list of commands
>>> >     >   void execute() {
>>> >     >     DeferredCommand.addCommand(new IncrementalCommand() {
>>> >     >       boolean executing;
>>> >     >       int currentIdx;
>>> >     >
>>> >     >       public boolean execute() {
>>> >     >         if (executing) return true;  // executor will keep
>>> looping
>>> >     >         // it's my turn now
>>> >     >         executing = true;
>>> >     >         AsyncCommand cmd = commands.get(currentIdx);
>>> >     >         cmd.execute(new AsyncCallback() {
>>> >     >           public void onFailure(Throwable e) { onSuccess(null); }
>>> >     >           public void onSuccess(Object o) {
>>> >     >             executing = false;
>>> >     >             ++currentIdx;
>>> >     >           }
>>> >     >       }
>>> >     >       // return point
>>> >     >   }
>>> >     > }
>>> >     >
>>> >     > The above method is actually still non-blocking. There's no
>>> guarantee
>>> >     > that my incremental command will finish executing before I reach
>>> >     > //return point. Did I miss anything?
>>> >
>>> >     Looking at your code a bit more closely (and while composing an
>>> >     example), I see that you want something that requires a bit more
>>> >     structure.
>>> >
>>> >     You have the IncrementalCommand() correctly implemented. Forget my
>>> >     previous answer.
>>> >
>>> >     Now that I really understand what you're asking (I think)...
>>> >
>>> >     I solve the problem using a state machine. Notice how the SM loops
>>> on
>>> >     DICTIONARYREAD until the command queue is empty.
>>> >
>>> >     DeferredCommand.addCommand(new IncrementalCommand() {
>>> >      @Override
>>> >      public boolean execute() {
>>> >        switch (startupState) {
>>> >          case INITIAL:
>>> >            timer.scheduleRepeating(600);
>>> >            startupState = StartupState.DICTIONARYREAD;
>>> >            break;
>>> >
>>> >          case DICTIONARYREAD:
>>> >            if (dictionaryRequest.getDictionaryPages()) {
>>> >               break;
>>> >            }
>>> >
>>> >            startupState = StartupState.FINAL;
>>> >            break;
>>> >
>>> >          case FINAL:  // Kevin's RETURN POINT?
>>> >            timer.cancel();
>>> >            return false; // command is complete
>>> >          }
>>> >        return true;
>>> >     });
>>> >
>>> >     public boolean getDictionaryPages() {
>>> >      while (dictionaryRequestList.size() > 0) {
>>> >        if (busy) {
>>> >          return true;
>>> >        }
>>> >        dictionaryRequestList.pop().execute(); // RPC and BUSY mutex
>>> >      }
>>> >      return false;
>>> >     }
>>> >
>>> >     --
>>> >     You received this message because you are subscribed to the Google
>>> >     Groups "Google Web Toolkit" group.
>>> >     To post to this group, send email to
>>> >     google-web-toolkit@googlegroups.com
>>> >     <mailto:google-web-toolkit@googlegroups.com>.
>>> >     To unsubscribe from this group, send email to
>>> >     
>>> > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>>> >     
>>> > <mailto:google-web-toolkit%2bunsubscr...@googlegroups.com<google-web-toolkit%252bunsubscr...@googlegroups.com>
>>> >.
>>> >     For more options, visit this group at
>>> >     http://groups.google.com/group/google-web-toolkit?hl=en.
>>> >
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups "Google Web Toolkit" group.
>>> > To post to this group, send email to
>>> google-web-tool...@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>>> .
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/google-web-toolkit?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google Web Toolkit" group.
>>> To post to this group, send email to google-web-toolkit@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to
>>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to