ACE_Token::ACE_Token_Queue Struct Reference

Collaboration diagram for ACE_Token::ACE_Token_Queue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Token_Queue (void)
 Constructor.

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

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


Public Attributes

ACE_Token_Queue_Entryhead_
 Head of the list of waiting threads.

ACE_Token_Queue_Entrytail_
 Tail of the list of waiting threads.


Constructor & Destructor Documentation

ACE_Token::ACE_Token_Queue::ACE_Token_Queue void   ) 
 

Constructor.

Definition at line 82 of file Token.cpp.

References ACE_TRACE.

00083   : head_ (0),
00084     tail_ (0)
00085 {
00086   ACE_TRACE ("ACE_Token::ACE_Token_Queue::ACE_Token_Queue");
00087 }


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 127 of file Token.cpp.

References ACE_Token::ACE_Token_Queue_Entry::next_.

Referenced by ACE_Token::renew(), and ACE_Token::shared_acquire().

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

void ACE_Token::ACE_Token_Queue::remove_entry ACE_Token_Queue_Entry  ) 
 

Remove a waiter from the queue.

Definition at line 93 of file Token.cpp.

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

Referenced by ACE_Token::renew(), and ACE_Token::shared_acquire().

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


Member Data Documentation

ACE_Token_Queue_Entry* ACE_Token::ACE_Token_Queue::head_
 

Head of the list of waiting threads.

Definition at line 276 of file Token.h.

Referenced by 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 279 of file Token.h.


The documentation for this struct was generated from the following files:
Generated on Thu Nov 9 11:31:41 2006 for ACE by doxygen 1.3.6