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

Question about the Connection#4.

Hi, Matthrew,
In the file "Config.Server" of sample codes in the connection#4, you increased the ThreadPool.Client.Size to 4 and commented that " Since the server makes calls from an AMI callback its necessary to increase the size of the client thread pool."
My question is that whether the "increasing" is necessary otherwise will lead to deadlock or is preferable otherwise may lead to the thread starvation?
If the latter, why did you not increase the ThreadPool.Server.Size? :confused:
I am always afraid of the deadlock when I am programming using ICE, especially when I have to select a proper thread number. So far as to me , what I can do is to avoid the nested callbacks :(

Hope getting your help.

Thank you .



  • matthew
    matthew NL, Canada
    AMI replies are dispatched using the client side thread pool, hence it must be increased not the server side. If the thread pool size isn't correct the application will deadlock (unless you are using timeouts). See 30.3.4 in the Ice manual for more details.

    Regards, Matthew
  • Thank you Matthrew. I have read the 30.3.4 carefully again. It's helpful. But I still have some questions ;) .
    If the thread pool size isn't correct the application will deadlock
    You are right. But so far as the sample codes in #4, it seems that the deadlock would not happen and the "increasing" of the client threadpool size is only to deal with the "simultaneous callbacks", that is, to deal with the thread starvation for the situation where many invitees agree or reject the invitations and make the callbacks at the same time.
    similarly, I think the server threadpool size also should be increased in case that many invitations from many users arrive at the chat server at the same time. In current configure, these invitations are serialized and then dispacthed asynchronously.
    In a word, I think that since we have increased the client thread pool size to deal with the simultaneous callbacks, we'd better increase the server threadpool size to deal with the simultaneous requests.

    2) The value 4 is set only by experiences or obey some rules such as in the Nested demo ,which used a sz*2 formula?

    Best Regards-OrNot
  • matthew
    matthew NL, Canada
    Sorry, the configuration file comment is incorrect on this point.

    The server as it stands can actually can work with a client side thread pool of size 1 since the AMI callback only makes replies on an AMD callback object. The AMD callback sends the message in the calling thread, and glacier2 cannot block.

    The thread pools, as you say, can be set larger to allow higher concurrency.

    Regards, Matthew