Archived

This forum has been archived. Please start a new discussion on GitHub.

how to match different request-response in ami call?

Hi, all
I've come into a problem which I think may be encountered by others too. When I use the mechanism of AMI, as ICE's Doc show:
class AMI_callback {
virtual void ice_response(...);
};
AMI_callbackPtr cb = new AMI_callbackI;
model->interpolate_async(cb,grid,0);//first call
model->interpolate_async(cb,grid,0);//call twice

My problem is, how could I match the response and the request of these two calls when there's only one ice_response method?
Insert a serial no into each call's input&output params may be a solution, but is there anything better and more graceful?

Comments

  • marc
    marc Florida
    You must not reuse an AMI callback object for a new call before the first call has returned. If you do so, all kinds of things can go wrong. Once the first call returns, you can reuse the same object for a new call. In this case, it's also clear which response belongs to which call.

    If you must do several calls at the same time without waiting for the response, use a separate AMI callback object for each of these calls.