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

Is there AMI style ice_getConnection?

I try to combine Bidirectional Connections and AMI in my project , I use the QtDispatcher atrributted by alex, and I try to avoid deadlock by using begin_xx end_xx AMI call ,and uncheckCast.. , everything works well except the ice_getConnection is called during

it seems to hang,and I can not find the begin_ice_getConnect() in ICE's api,how can I fix or avoid it?


  • mes
    mes California
    Hi Roland,

    As you suspected, calling ice_getConnection behaves similarly to making a synchronous proxy invocation, in that calling it from the Qt dispatch thread will cause the program to hang.

    The proxy also provides the method ice_getCachedConnection, but this method returns null if no connection has been established yet.

    To avoid blocking, I recommend calling begin_ice_ping. Upon successful completion, the connection will be established and you can do something like this in the completion callback:
    Ice::ConnectionPtr conn = proxy->ice_getCachedConnection();
    We'll consider adding a better solution to a future Ice release.

  • Thanks Mark, I think it's the best solution we can figure out right now.