#include <Local_Tokens.h>
Collaboration diagram for ACE_Token_Proxy_Queue:

Public Methods | |
| ACE_Token_Proxy_Queue (void) | |
| Constructor. More... | |
| ~ACE_Token_Proxy_Queue (void) | |
| Destructor. More... | |
| void | enqueue (ACE_TPQ_Entry *new_entry, int position) |
| const ACE_TPQ_Entry * | head (void) |
| Top of the queue. More... | |
| void | dequeue (void) |
| Remove the top waiter. More... | |
| void | remove (const ACE_TPQ_Entry *remove_me) |
| Remove the waiter whose proxy ref matches remove_me. More... | |
| int | size (void) |
| The number of waiters. More... | |
| void | dump (void) const |
| Dump the state of the class. More... | |
Protected Attributes | |
| ACE_TPQ_Entry * | head_ |
| Head. More... | |
| ACE_TPQ_Entry * | tail_ |
| Tail. More... | |
| int | size_ |
| Size. More... | |
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 299 of file Local_Tokens.h.
|
|
Constructor.
Definition at line 274 of file Local_Tokens.cpp. References ACE_TRACE.
|
|
|
Destructor.
|
|
|
Remove the top waiter.
Definition at line 335 of file Local_Tokens.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, head_, LM_ERROR, ACE_TPQ_Entry::next_, and size_. Referenced by ACE_Mutex_Token::release, and ACE_Mutex_Token::renew.
00336 {
00337 ACE_TRACE ("ACE_Token_Proxy_Queue::dequeue");
00338
00339 if (head_ == 0)
00340 return;
00341
00342 ACE_TPQ_Entry *temp = this->head_;
00343
00344 this->head_ = this->head_->next_;
00345
00346 temp->next_ = 0;
00347
00348 --this->size_;
00349
00350 if (this->head_ == 0 && this->size_ != 0)
00351 ACE_ERROR ((LM_ERROR,
00352 ACE_LIB_TEXT ("incorrect size = %d\n"),
00353 this->size_));
00354 }
|
|
|
Dump the state of the class.
Definition at line 259 of file Local_Tokens.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_TPQ_Entry::dump, head_, LM_DEBUG, and size_. Referenced by ACE_Tokens::dump.
00260 {
00261 ACE_TRACE ("ACE_Token_Proxy_Queue::dump");
00262 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00263 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy_Queue::dump:\n")
00264 ACE_LIB_TEXT (" size_ = %d\n"),
00265 size_));
00266 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("head_ and tail_\n")));
00267 if (this->head_ != 0)
00268 this->head_->dump ();
00269
00270 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy_Queue::dump end.\n")));
00271 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00272 }
|
|
||||||||||||
|
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 283 of file Local_Tokens.cpp. References ACE_TRACE, head_, ACE_TPQ_Entry::next_, size_, and tail_. 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.
00285 {
00286 ACE_TRACE ("ACE_Token_Proxy_Queue::enqueue");
00287 tpq->next_ = 0;
00288
00289 ++this->size_;
00290
00291 if (this->head_ == 0)
00292 {
00293 // make tpq the entire list
00294 this->head_ = this->tail_ = tpq;
00295 return;
00296 }
00297
00298 if (position == 0)
00299 {
00300 // make head of list
00301 tpq->next_ = this->head_;
00302 this->head_ = tpq;
00303 return;
00304 }
00305
00306 if (position == -1)
00307 {
00308 // stick at back of list
00309 this->tail_->next_ = tpq;
00310 this->tail_ = tpq;
00311 return;
00312 }
00313
00314 // walk through list to insertion point
00315 ACE_TPQ_Entry *temp = head_;
00316
00317 for (int x = position;
00318 x > 1;
00319 --x)
00320 {
00321 // end of queue?
00322 if (temp->next_ == 0)
00323 break;
00324 // advance pointer
00325 else
00326 temp = temp->next_;
00327 }
00328
00329 // insert new tpq after temp
00330 tpq->next_ = temp->next_;
00331 temp->next_ = tpq;
00332 }
|
|
|
Top of the queue.
|
|
|
Remove the waiter whose proxy ref matches remove_me.
Definition at line 375 of file Local_Tokens.cpp. References ACE_TRACE, head_, ACE_TPQ_Entry::next_, size_, and tail_. Referenced by ACE_Tokens::make_owner.
00376 {
00377 ACE_TRACE ("ACE_Token_Proxy_Queue::remove");
00378 // sanity
00379 if ((remove_me == 0) || (this->head_ == 0))
00380 return;
00381
00382 // is it the head?
00383 if (this->head_ == remove_me) // pointer comparison.
00384 {
00385 this->head_ = this->head_->next_;
00386 if (this->head_ == 0)
00387 this->tail_ = 0;
00388
00389 --this->size_;
00390 return;
00391 }
00392
00393 ACE_TPQ_Entry *temp = this->head_;
00394 ACE_TPQ_Entry *previous = 0;
00395
00396 // is it in the middle or tail?
00397 while (temp != 0)
00398 {
00399 if (temp == remove_me)
00400 {
00401 // previous should never be null since the first if
00402 // conditional should always be false
00403 previous->next_ = temp->next_;
00404 // is it the tail?
00405 if (this->tail_ == temp)
00406 this->tail_ = previous;
00407
00408 --this->size_;
00409 return;
00410 }
00411
00412 previous = temp;
00413 temp = temp->next_;
00414 }
00415
00416 // it wasn't in the list.
00417 return;
00418 }
|
|
|
The number of waiters.
Referenced by ACE_RW_Token::renew, and ACE_Mutex_Token::renew. |
|
|
Definition at line 302 of file Local_Tokens.h. |
|
|
Head.
Definition at line 338 of file Local_Tokens.h. |
|
|
Size.
Definition at line 344 of file Local_Tokens.h. |
|
|
Tail.
Definition at line 341 of file Local_Tokens.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002