I refactored the code a bit and pushed to my repo:

Replaced ReceiverListener interface with Stream for clarity and to simplify. 

Implemented matching of received event to target stream in Receiver using a 
lookup instead of looping in the Stream. More efficient, not affetced by number 
of streams. I used a hash map inside a hash map which should be efficient. To 
lookup:

            int appId = event.getAppId();
            int streamId = event.getStreamId();

            /*
             * Match appId and streamId in event to the target stream and pass
             * the event to the target stream. TODO: make this more efficient
             * for the case in which we send the same event to multiple PEs.
             */
            try {
                streams.get(appId).get(streamId).receiveEvent(event);
            ...

Bruce, please review when you get a chance. I tried to also move the Sender 
functionality to Event but that didn't look nice at the end so I left it as is.

-leo


Reply via email to