The problem I have is something like a single producer multiple consumer problem. Except the consumer are "different" and I need a way of "peek"ing on the new item (to check who its for) before taking it.
The problem is actually a single server thread that serves multiple client threads. Client will request info, then server should reply to this client
How can I do that? A possibility is a loop like:
while (true) { if (q.peek() ... check here ...) { // do something } else { Sleep(...); // prevent taking up too much CPU? } } But doesn't seem ideal/right?