diff options
author | Steve Huston <shuston@riverace.com> | 2000-07-26 03:00:24 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2000-07-26 03:00:24 +0000 |
commit | 137beb6f60e3f68c66807fef29456e24b748aa30 (patch) | |
tree | bdc4fff2cd8e0c4cbac52a62c7432facc91831e6 /ace/Future.cpp | |
parent | 1fbdd00cc61d2d0b24c1ebe1429da3bbf5ce6296 (diff) | |
download | ATCD-137beb6f60e3f68c66807fef29456e24b748aa30.tar.gz |
ChangeLogTag:Tue Jul 25 22:35:31 2000 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/Future.cpp')
-rw-r--r-- | ace/Future.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
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<T>::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; |