Originally posted by Steve Morrow:
Operator Precedence
Originally posted by Kristin Stromberg:
I think you're confusing associativity with precedence. They're not the same thing.
Originally posted by Edwin Dalorzo:
Now, if the shifted value is assigned back to a byte the upper 16 bits will be discarded.
Hope it helps.
[ June 18, 2005: Message edited by: Edwin Dalorzo ]
Originally posted by John Ryan:
Hi all,
When a left shift is performed on a byte it is first promoted to an int. When you want the result of the shifted byte value is it true that you must discard the top three bytes of the int result?. Is this because the top three bytes are used only for representing the sign of a byte or a short vaue?
This statement is confusing me because I thought the sign of a byte/short/int was only represented by the right most bit?
Cheers,
John
Originally posted by David Harkness:
My first instinct would be to have designed it such that only one thread was reading from the socket and placing the messages into two separate queues (to be able to tune them separately). Then I would have two thread pools processing the queues.
Note that this is very similar to your design. The difference is that if all three reader threads are busy handling type 2 messages at once, the socket starts backing up. But I see a few advantages to this method:
Both types of messages are treated exactly the same up to the point where the actual handling of the message differs: they both get read and put into a queue. Each queue and its respective thread pool can be tuned more easily. Adding new types of messages just means a new queue. You could have a single thread pool to handle message queues by applying an algorithm to choose which queue to poll based on queue priority and backlog.
I think at this point you really need to know what each reader thread is doing by adding logging if you haven't already. Figure out how long it takes each thread to complete its task (put a type 1 message on the queue, handle a type 2 message, handle a type 1 message). With that you should be able to tune your thread pools without making another architecture change.