I don't know if the title makes sense but working with gwt for about 2
years, I often find myself in the position to mix both asynchronous and
synchronous (blocking) apis. It's easy to transform a synchronous call to
asynchronous, but the other way around is not immediately obvious to me,
especially in the context of the single-threaded browser environment.
Imagine I the following:
abstract class GetList<T> {
abstract void execute(AsyncCallback<List<T>> callback);
}
class GetContactList extends GetList<Contact> {
void execute(AsyncCallback<List<Contact>> callback) { /* implementation */
}
}
class GetAddressList extends GetList<Address> {
void execute(AsyncCallback<List<Address>> callback) { /* implementation */
}
}
class GetPhoneList extends GetList<Phone> {
void execute(AsyncCallback<List<Phone>> callback) { /* implementation */ }
}
now imagine I keep a list of GetList objects:
List<GetList> commands = Arrays.asList(new GetContactList(), new
GetAddressList(), new GetPhoneList());
and I have an executor that executes these commands:
class Executor {
List<? extends GetList<?>> commands;
Executor(List<? extends GetList<?>> commands) {
this.commands = commands;
}
void execute() {
// XXX:
}
}
Now, for whatever reason, I need my execute() method to be a blocking call
(synchronous). It should terminate after all GetList calls are returned. How
can I achieve this?
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.