summaryrefslogtreecommitdiff
path: root/TAO/tao/Leader_Follower.cpp
diff options
context:
space:
mode:
authorbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-27 21:16:45 +0000
committerbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-27 21:16:45 +0000
commit470675732dacbbaa2c6a5429d976662b764604c2 (patch)
tree5702c2da2272776f83c58714eebc49993faa32f4 /TAO/tao/Leader_Follower.cpp
parentd9d8058001f213d613eb23c0d9cd342419724740 (diff)
downloadATCD-470675732dacbbaa2c6a5429d976662b764604c2.tar.gz
ChangeLogTag: Tue Mar 27 15:08:41 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Leader_Follower.cpp')
-rw-r--r--TAO/tao/Leader_Follower.cpp100
1 files changed, 21 insertions, 79 deletions
diff --git a/TAO/tao/Leader_Follower.cpp b/TAO/tao/Leader_Follower.cpp
index 13d9e88fbef..54b04613a25 100644
--- a/TAO/tao/Leader_Follower.cpp
+++ b/TAO/tao/Leader_Follower.cpp
@@ -18,89 +18,17 @@ TAO_Leader_Follower::~TAO_Leader_Follower (void)
this->reactor_ = 0;
}
-TAO_Leader_Follower::TAO_Follower_Node::TAO_Follower_Node (TAO_SYNCH_CONDITION* follower_ptr)
- : follower_ (follower_ptr),
- next_ (0)
-{
-
-}
-
-TAO_Leader_Follower::TAO_Follower_Queue::TAO_Follower_Queue (void)
- : head_ (0),
- tail_ (0)
-{
-
-}
-
-int
-TAO_Leader_Follower::TAO_Follower_Queue::insert (TAO_Follower_Node* node)
-{
- TAO_Follower_Node* curr = 0;
-
- // Check if there is already an existing entry
- for (curr = this->head_;
- curr != 0 && curr != node;
- curr = curr->next_)
- ;
- // An entry exists already in the queue
- if (curr == node)
- return 1;
- else
- {
- // Add the node to the tail and modify the pointers
- TAO_Follower_Node* temp = this->tail_;
- this->tail_ = node;
- if (this->head_ == 0)
- this->head_ = this->tail_;
- else
- temp->next_ = this->tail_;
- }
- return 0;
-}
-
-int
-TAO_Leader_Follower::TAO_Follower_Queue::remove (TAO_Follower_Node* node)
-{
- TAO_Follower_Node* prev = 0;
- TAO_Follower_Node* curr = 0;
-
- // No followers in queue, return
- if (this->head_ == 0)
- return -1;
-
- for (curr = this->head_;
- curr != 0 && curr != node;
- curr = curr->next_)
- {
- prev = curr;
- }
-
- // Entry not found in the queue
- if (curr == 0)
- return -1;
- // Entry found at the head of the queue
- else if (prev == 0)
- this->head_ = this->head_->next_;
- else
- prev->next_ = curr->next_;
- // Entry at the tail
- if (curr->next_ == 0)
- this->tail_ = prev;
-
- return 0;
-}
-
-
TAO_SYNCH_CONDITION*
TAO_Leader_Follower::get_next_follower (void)
{
- // If the queue is empty return
- if (this->follower_set_.is_empty())
- return 0;
+ ACE_Unbounded_Set_Iterator<TAO_SYNCH_CONDITION *> iterator (
+ this->follower_set_);
- TAO_Follower_Node* next_follower = this->follower_set_.head_;
+ if (iterator.first () == 0)
+ // means set is empty
+ return 0;
- TAO_SYNCH_CONDITION *cond = next_follower->follower_;
+ TAO_SYNCH_CONDITION *cond = *iterator;
#if defined (TAO_DEBUG_LEADER_FOLLOWER)
ACE_DEBUG ((LM_DEBUG,
@@ -115,7 +43,7 @@ TAO_Leader_Follower::get_next_follower (void)
// The follower may not be there if the reply is received while the
// consumer is not yet waiting for it (i.e. it send the request but
// has not blocked to receive the reply yet)
- (void) this->remove_follower (next_follower); // Ignore errors..
+ (void) this->remove_follower (cond); // Ignore errors..
return cond;
}
@@ -225,3 +153,17 @@ TAO_Leader_Follower::reset_client_thread (void)
this->orb_core_->reactor ()->end_reactor_event_loop ();
}
}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+template class ACE_Node<TAO_SYNCH_CONDITION*>;
+template class ACE_Unbounded_Set<TAO_SYNCH_CONDITION*>;
+template class ACE_Unbounded_Set_Iterator<TAO_SYNCH_CONDITION*>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+#pragma instantiate ACE_Node<TAO_SYNCH_CONDITION*>
+#pragma instantiate ACE_Unbounded_Set<TAO_SYNCH_CONDITION*>
+#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_SYNCH_CONDITION*>
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */