Archived

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

thread pool (block reading?)

I has great interest in ICE. Recently I has read the source code of threadpool.
I find Ice uses leader-follower thread model. There are some critical areas that only one thread can run and Ice uses the "_promote" to control it.
Only one thread runs function finished(handle) or message()(at the begin of those functions) can release the "_promote", and another thread can go into the critical area and to epoll other message. But before handler->message(), the thread should execute read(handler); in the function read(handler), the thread must read all bytes of the message, so my question is"If the connection is slow and message body is huge, the thread has to stop at here and the thread don‘t release the "_promote", and other threads have no chance to epoll new data(but can execute the code of object method) 。If the server has a lot of connections, i think it will be a bottleneck“
i'm sorry for my poor english.

Comments

  • marc
    marc Florida
    The reading is done non-blocking, so if there is no more data to read, and the message is not complete yet, the thread will return to the thread pool and continue to epoll/select. It therefore does not matter whether a client is slow or not, since the leader thread won't wait for a slow client.

    Note that in general, explaining Ice internals is out of the scope of the support we can provide here in our forums.
  • Note that in general, explaining Ice internals is out of the scope of the support we can provide here in our forums.[/QUOTE]

    thank you for your replying, I just wonder why Ice using blocking reading.
    your code is smart and i thought when poll's timeout is zero, it would block.
  • marc
    marc Florida
    Note that Ice is not using blocking reading.
  • marc wrote: »
    Note that Ice is not using blocking reading.
    thanks.
    i have understood this part code. Ice not using blocking reading。
    it is smart code