#include <Local_Tokens.h>
Collaboration diagram for ACE_Token_Proxy_Queue:
Public Member Functions | |
ACE_Token_Proxy_Queue (void) | |
Constructor. | |
~ACE_Token_Proxy_Queue (void) | |
Destructor. | |
void | enqueue (ACE_TPQ_Entry *new_entry, int position) |
const ACE_TPQ_Entry * | head (void) |
Top of the queue. | |
void | dequeue (void) |
Remove the top waiter. | |
void | remove (const ACE_TPQ_Entry *remove_me) |
Remove the waiter whose proxy ref matches remove_me. | |
int | size (void) |
The number of waiters. | |
void | dump (void) const |
Dump the state of the class. | |
Protected Attributes | |
ACE_TPQ_Entry * | head_ |
Head. | |
ACE_TPQ_Entry * | tail_ |
Tail. | |
int | size_ |
Size. | |
Friends | |
class | ACE_TPQ_Iterator |
Not a public interface. This queue holds all the token proxies waiting for ownership of a token. Along with the proxy reference, it also stores the nesting level, client id, and a magic cookie from the proxy. This queue stores the ACE_TPQ_Entries by pointer values. It DOES NOT make copies. Thus, the user is responsible to ensure that the TPQ's stick around. This is motivated by the need to reduce dynamic memory allocation.
Definition at line 304 of file Local_Tokens.h.
|
Constructor.
Definition at line 304 of file Local_Tokens.cpp. References ACE_TRACE.
|
|
Destructor.
|
|
Remove the top waiter.
Definition at line 365 of file Local_Tokens.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and ACE_TPQ_Entry::next_. Referenced by ACE_Mutex_Token::release(), and ACE_Mutex_Token::renew().
00366 { 00367 ACE_TRACE ("ACE_Token_Proxy_Queue::dequeue"); 00368 00369 if (head_ == 0) 00370 return; 00371 00372 ACE_TPQ_Entry *temp = this->head_; 00373 00374 this->head_ = this->head_->next_; 00375 00376 temp->next_ = 0; 00377 00378 --this->size_; 00379 00380 if (this->head_ == 0 && this->size_ != 0) 00381 ACE_ERROR ((LM_ERROR, 00382 ACE_LIB_TEXT ("incorrect size = %d\n"), 00383 this->size_)); 00384 } |
|
Dump the state of the class.
Definition at line 287 of file Local_Tokens.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_TPQ_Entry::dump(), and LM_DEBUG. Referenced by ACE_Tokens::dump().
00288 { 00289 #if defined (ACE_HAS_DUMP) 00290 ACE_TRACE ("ACE_Token_Proxy_Queue::dump"); 00291 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00292 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy_Queue::dump:\n") 00293 ACE_LIB_TEXT (" size_ = %d\n"), 00294 size_)); 00295 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("head_ and tail_\n"))); 00296 if (this->head_ != 0) 00297 this->head_->dump (); 00298 00299 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy_Queue::dump end.\n"))); 00300 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00301 #endif /* ACE_HAS_DUMP */ 00302 } |
|
Enqueue a proxy, nesting level, client_id, and a magic cookie at the given position in the list. If the position is -1, we enqueue at the end of the list (I think). Definition at line 313 of file Local_Tokens.cpp. References ACE_TRACE, and ACE_TPQ_Entry::next_. Referenced by ACE_RW_Token::acquire(), ACE_Mutex_Token::acquire(), ACE_Tokens::make_owner(), ACE_RW_Token::renew(), ACE_Mutex_Token::renew(), ACE_RW_Token::tryacquire(), and ACE_Mutex_Token::tryacquire().
00315 { 00316 ACE_TRACE ("ACE_Token_Proxy_Queue::enqueue"); 00317 tpq->next_ = 0; 00318 00319 ++this->size_; 00320 00321 if (this->head_ == 0) 00322 { 00323 // make tpq the entire list 00324 this->head_ = this->tail_ = tpq; 00325 return; 00326 } 00327 00328 if (position == 0) 00329 { 00330 // make head of list 00331 tpq->next_ = this->head_; 00332 this->head_ = tpq; 00333 return; 00334 } 00335 00336 if (position == -1) 00337 { 00338 // stick at back of list 00339 this->tail_->next_ = tpq; 00340 this->tail_ = tpq; 00341 return; 00342 } 00343 00344 // walk through list to insertion point 00345 ACE_TPQ_Entry *temp = head_; 00346 00347 for (int x = position; 00348 x > 1; 00349 --x) 00350 { 00351 // end of queue? 00352 if (temp->next_ == 0) 00353 break; 00354 // advance pointer 00355 else 00356 temp = temp->next_; 00357 } 00358 00359 // insert new tpq after temp 00360 tpq->next_ = temp->next_; 00361 temp->next_ = tpq; 00362 } |
|
Top of the queue.
|
|
Remove the waiter whose proxy ref matches remove_me.
Definition at line 405 of file Local_Tokens.cpp. References ACE_TRACE, and ACE_TPQ_Entry::next_. Referenced by ACE_Tokens::make_owner().
00406 { 00407 ACE_TRACE ("ACE_Token_Proxy_Queue::remove"); 00408 // sanity 00409 if ((remove_me == 0) || (this->head_ == 0)) 00410 return; 00411 00412 // is it the head? 00413 if (this->head_ == remove_me) // pointer comparison. 00414 { 00415 this->head_ = this->head_->next_; 00416 if (this->head_ == 0) 00417 this->tail_ = 0; 00418 00419 --this->size_; 00420 return; 00421 } 00422 00423 ACE_TPQ_Entry *temp = this->head_; 00424 ACE_TPQ_Entry *previous = 0; 00425 00426 // is it in the middle or tail? 00427 while (temp != 0) 00428 { 00429 if (temp == remove_me) 00430 { 00431 // previous should never be null since the first if 00432 // conditional should always be false 00433 previous->next_ = temp->next_; 00434 // is it the tail? 00435 if (this->tail_ == temp) 00436 this->tail_ = previous; 00437 00438 --this->size_; 00439 return; 00440 } 00441 00442 previous = temp; 00443 temp = temp->next_; 00444 } 00445 00446 // it wasn't in the list. 00447 return; 00448 } |
|
The number of waiters.
Referenced by ACE_Tokens::no_of_waiters(), ACE_RW_Token::renew(), and ACE_Mutex_Token::renew(). |
|
Definition at line 307 of file Local_Tokens.h. |
|
Head.
Definition at line 343 of file Local_Tokens.h. |
|
Size.
Definition at line 349 of file Local_Tokens.h. |
|
Tail.
Definition at line 346 of file Local_Tokens.h. |