Question

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 .

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top