Hi, It seems to me that since the function oneway() and futureResponse::getResponse() can throw exceptions, the code should make sure that the requestMap is cleared in all cases. I would propose something like:
try { // Send the request. next->oneway( command ); // Get the response. response = futureResponse->getResponse( timeout ); } catch(.) { // Perform cleanup on the map. synchronized( &mapMutex ){ // We do not want memory corruption by accessing freed // futureResponse objects by accident in onCommand() - get this thing out // of the map. requestMap.erase( command->getCommandId() ); } throw; } synchronized( &mapMutex ){ // We've done our waiting - get this thing out // of the map. requestMap.erase( command->getCommandId() ); } Olivier Langlois C++ Technical Lead STREAMTHEWORLD t. 1 866 448 4037 ext. 675 t. 1 514 448 4037 ext. 675 f. 1 514 807 1861 olivier.langl...@streamtheworld.com streamtheworld.com StreamTheWorld launches its new BlackBerry application. Learn more