From 137beb6f60e3f68c66807fef29456e24b748aa30 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Wed, 26 Jul 2000 03:00:24 +0000 Subject: ChangeLogTag:Tue Jul 25 22:35:31 2000 Steve Huston --- ace/Future.cpp | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'ace/Future.cpp') diff --git a/ace/Future.cpp b/ace/Future.cpp index f70f8df83bb..e42c1bf99a4 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -144,33 +144,37 @@ ACE_Future_Rep::set (const T &r, // If the value is already produced, ignore it... if (this->value_ == 0) { - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->value_ready_mutex_, -1)); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, + ace_mon, + this->value_ready_mutex_, + -1)); // Otherwise, create a new result value. Note the use of the // Double-checked locking pattern to avoid multiple allocations. - if (this->value_ == 0) - ACE_NEW_RETURN (this->value_, - T (r), - -1); - - // Remove and notify all subscribed observers. - ACE_TYPENAME OBSERVER_COLLECTION::iterator iterator = - this->observer_collection_.begin (); - - ACE_TYPENAME OBSERVER_COLLECTION::iterator end = - this->observer_collection_.end (); - - for (; - iterator != end; - ++iterator) + if (this->value_ == 0) // Still no value, so proceed { - OBSERVER *observer = *iterator; - observer->update (caller); + ACE_NEW_RETURN (this->value_, + T (r), + -1); + + // Remove and notify all subscribed observers. + ACE_TYPENAME OBSERVER_COLLECTION::iterator iterator = + this->observer_collection_.begin (); + + ACE_TYPENAME OBSERVER_COLLECTION::iterator end = + this->observer_collection_.end (); + + for (; + iterator != end; + ++iterator) + { + OBSERVER *observer = *iterator; + observer->update (caller); + } + + // Signal all the waiting threads. + return this->value_ready_.broadcast (); } - - // Signal all the waiting threads. - return this->value_ready_.broadcast (); - // Destructor releases the lock. } return 0; -- cgit v1.2.1