"Timothy Ritchey"
We have been using shared_ptrs pretty successfully throughout our application, but I have run across something that has just completely stumped me. BTW - this is a Windows .NET 2003 + Intel 8.1 compiler compiling in Debug mode on a multi-processor machine (dual Xeon Dell workstation).
The code in question is:
void Router::routeEnvelope(shared_ptr<Envelope> envelope) {
if(!running || !envelope) return;
GUID target = envelope->getTo(); if(target == guid) { // PATH 1
// check to see if it is a failure envelope shared_ptr<EnvelopeFailure> envelopeFailure = shared_dynamic_cast<EnvelopeFailure>(envelope); if(envelopeFailure) { // there was a problem sending the original envelope failedEnvelope(envelopeFailure->getFrom()); }
I'm not sure if this will help, but the following will limit the scope of 'envelopeFailure'. This may be important if your code is reentrant through 'envelopeController.injectEnvelope'. I'm not sure what 'shared_dynamic_cast' is above, but assume you meant 'dynamic_pointer_cast'? if( shared_ptr<EnvelopeFailure> envelopeFailure = dynamic_pointer_cast<EnvelopeFailure>(envelope) ) { failedEnvelope( envelopeFailure->getFrom() ); }
// pass it on up the stack envelopeController.injectEnvelope(envelope);
} else { // PATH 2 mutex::scoped_lock lock(envelopeQueueMonitor); envelopeQueue.push(envelope); envelopeReady.notify_all(); } }
Jeff Flinn