mklaca edited a comment on pull request #97: URL: https://github.com/apache/qpid-broker-j/pull/97#issuecomment-875630250
Hi @alex-rufous, your statement is not correct: > The #doWork() can only be invoked multiple times if there are free IO threads to process other connections Let assume situation when there is 2 threads in the thread pool, a single selector and a single connection. The selector task occupies one thread A and the second thread B is kept busy by the connection. Based on your statement the connection working loop is interrupted because there is not any free thread. The connection is re-scheduled and picked up by the same thread B for processing again. The thread B is in loop: 1. The thread picks up the connection from the working queue. 2. The thread invokes #doWork(). 3. The thread interrupts the loop of #doWork() because there is not any free thread. 4. The connection is returned to the queue. The thread B drops and picks up the same single connection and this useless iteration repeats again and again. The correct condition should be: > The #doWork() can only be invoked multiple times if there is not any another connections/job to process The suggested change keeps the "fairness functionality": If the working queue is empty then all connections are being processed by some thread and there is not any abandoned connection. Hence, no need to interrupt #doWork() loop because every connection/message has a thread. If the working queue is not empty then there is a waiting connection. The #doWork() loop is interrupted after the first call of the #doWork() method and the thread picks up the waiting connection from the queue. If there is any waiting message then it's processing will not be blocked. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
