Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Token::ACE_Token_Queue Struct Reference

Collaboration diagram for ACE_Token::ACE_Token_Queue:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Token_Queue (void)
 Constructor. More...

void remove_entry (ACE_Token_Queue_Entry *)
 Remove a waiter from the queue. More...

void insert_entry (ACE_Token_Queue_Entry &entry, int requeue_position=-1)
 Insert a waiter into the queue. More...


Public Attributes

ACE_Token_Queue_Entryhead_
 Head of the list of waiting threads. More...

ACE_Token_Queue_Entrytail_
 Tail of the list of waiting threads. More...


Constructor & Destructor Documentation

ACE_Token::ACE_Token_Queue::ACE_Token_Queue void   
 

Constructor.

Definition at line 79 of file Token.cpp.

References ACE_TRACE.

00080   : head_ (0),
00081     tail_ (0)
00082 {
00083   ACE_TRACE ("ACE_Token::ACE_Token_Queue::ACE_Token_Queue");
00084 }


Member Function Documentation

void ACE_Token::ACE_Token_Queue::insert_entry ACE_Token_Queue_Entry   entry,
int    requeue_position = -1
 

Insert a waiter into the queue.

Definition at line 124 of file Token.cpp.

References head_, ACE_Token::ACE_Token_Queue_Entry::next_, and tail_.

Referenced by ACE_Token::renew.

00126 {
00127   if (this->head_ == 0)
00128     {
00129       // No other threads - just add me
00130       this->head_ = &entry;
00131       this->tail_ = &entry;
00132     }
00133   else if (requeue_position == -1)
00134     {
00135       // Insert at the end of the queue.
00136       this->tail_->next_ = &entry;
00137       this->tail_ = &entry;
00138     }
00139   else if (requeue_position == 0)
00140     {
00141       // Insert at head of queue.
00142       entry.next_ = this->head_;
00143       this->head_ = &entry;
00144     }
00145   else
00146     // Insert in the middle of the queue somewhere.
00147     {
00148       // Determine where our thread should go in the queue of waiters.
00149 
00150       ACE_Token::ACE_Token_Queue_Entry *insert_after = this->head_;
00151       while (requeue_position-- && insert_after->next_ != 0)
00152         insert_after = insert_after->next_;
00153 
00154       entry.next_ = insert_after->next_;
00155 
00156       if (entry.next_ == 0)
00157         this->tail_ = &entry;
00158 
00159       insert_after->next_ = &entry;
00160     }
00161 }

void ACE_Token::ACE_Token_Queue::remove_entry ACE_Token_Queue_Entry  
 

Remove a waiter from the queue.

Definition at line 90 of file Token.cpp.

References ACE_TRACE, head_, ACE_Token::ACE_Token_Queue_Entry::next_, and tail_.

Referenced by ACE_Token::renew.

00091 {
00092   ACE_TRACE ("ACE_Token::ACE_Token_Queue::remove_entry");
00093   ACE_Token_Queue_Entry *curr = 0;
00094   ACE_Token_Queue_Entry *prev = 0;
00095 
00096   if (this->head_ == 0)
00097     return;
00098 
00099   for (curr = this->head_;
00100        curr != 0 && curr != entry;
00101        curr = curr->next_)
00102     prev = curr;
00103 
00104   if (curr == 0)
00105     // Didn't find the entry...
00106     return;
00107   else if (prev == 0)
00108     // Delete at the head.
00109     this->head_ = this->head_->next_;
00110   else
00111     // Delete in the middle.
00112     prev->next_ = curr->next_;
00113 
00114   // We need to update the tail of the list if we've deleted the last
00115   // entry.
00116   if (curr->next_ == 0)
00117     this->tail_ = prev;
00118 }


Member Data Documentation

ACE_Token_Queue_Entry* ACE_Token::ACE_Token_Queue::head_
 

Head of the list of waiting threads.

Definition at line 257 of file Token.h.

Referenced by insert_entry, remove_entry, ACE_Token::renew, and ACE_Token::wakeup_next_waiter.

ACE_Token_Queue_Entry* ACE_Token::ACE_Token_Queue::tail_
 

Tail of the list of waiting threads.

Definition at line 260 of file Token.h.

Referenced by insert_entry, and remove_entry.


The documentation for this struct was generated from the following files:
Generated on Mon Jun 16 12:58:23 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002