I have multiple producers, each pushing data into there own Blocking queues. The data from each producer is processed independently, (hence the separate queues).

My single consumer currently polls each of those queues, with a timeout on each.

Program works just fine, but I am trying to optimize, I don't like the "polling". Is this the most efficient way to approach this.?,

I have written the same app using a consumer per producer, but that profiled slightly worse.

thanks .

有帮助吗?

解决方案

Try to register the consumer as a listener on the queues, so that a change in the queue status informs the consumer without actively polling (Inversion of control).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top