ACE_TLI_Request_Queue Class Reference

Collaboration diagram for ACE_TLI_Request_Queue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_TLI_Request_Queue (void)
ACE_HANDLE open (ACE_HANDLE fd, int size)
int close (void)
int enqueue (const char device[], int restart, int rwflag)
int dequeue (ACE_TLI_Request *&ptr)
int remove (int sequence_number)
int is_empty (void) const
int is_full (void) const
ACE_TLI_Requestalloc (void)
void free (ACE_TLI_Request *node)
void dump (void) const

Public Attributes

 ACE_ALLOC_HOOK_DECLARE

Private Attributes

ACE_HANDLE handle_
int size_
int current_count_
ACE_TLI_Requestbase_
ACE_TLI_Requesttail_
ACE_TLI_Requestfree_list_

Constructor & Destructor Documentation

ACE_TLI_Request_Queue::ACE_TLI_Request_Queue void   ) 
 

Definition at line 226 of file TLI_Acceptor.cpp.

References ACE_TRACE.

00227   : size_ (0),
00228     current_count_ (0),
00229     base_ (0),
00230     tail_ (0),
00231     free_list_ (0)
00232 {
00233   ACE_TRACE ("ACE_TLI_Request_Queue::ACE_TLI_Request_Queue");
00234 }


Member Function Documentation

ACE_TLI_Request * ACE_TLI_Request_Queue::alloc void   ) 
 

Definition at line 95 of file TLI_Acceptor.cpp.

References ACE_TRACE, and ACE_TLI_Request::next_.

Referenced by ACE_TLI_Acceptor::accept(), enqueue(), and open().

00096 {
00097   ACE_TRACE ("ACE_TLI_Request_Queue::alloc");
00098   ACE_TLI_Request *temp = this->free_list_;
00099   this->free_list_ = this->free_list_->next_;
00100   return temp;
00101 }

int ACE_TLI_Request_Queue::close void   ) 
 

Definition at line 175 of file TLI_Acceptor.cpp.

References ACE_TRACE, ACE_TLI_Request::callp_, ACE_TLI_Request::handle_, and ACE_OS::t_free().

Referenced by ACE_TLI_Acceptor::close().

00176 {
00177   ACE_TRACE ("ACE_TLI_Request_Queue::close");
00178   int res = 0;
00179 
00180   for (int i = 0; i < this->size_; i++)
00181     {
00182       ACE_TLI_Request &item = this->base_[i];
00183 
00184       item.handle_ = ACE_INVALID_HANDLE;
00185       if (ACE_OS::t_free ((char *) item.callp_,
00186                           T_CALL) != 0)
00187         res = -1;
00188     }
00189 
00190   delete [] this->base_;
00191   this->base_ = 0;
00192   return res;
00193 }

int ACE_TLI_Request_Queue::dequeue ACE_TLI_Request *&  ptr  ) 
 

Definition at line 120 of file TLI_Acceptor.cpp.

References ACE_TRACE, and ACE_TLI_Request::next_.

Referenced by ACE_TLI_Acceptor::accept().

00121 {
00122   ACE_TRACE ("ACE_TLI_Request_Queue::dequeue");
00123   ptr = this->tail_->next_;
00124   this->tail_->next_ = ptr->next_;
00125   this->current_count_--;
00126   return 0;
00127 }

void ACE_TLI_Request_Queue::dump void   )  const
 

Definition at line 61 of file TLI_Acceptor.cpp.

References ACE_TRACE.

00062 {
00063 #if defined (ACE_HAS_DUMP)
00064   ACE_TRACE ("ACE_TLI_Request_Queue::dump");
00065 #endif /* ACE_HAS_DUMP */
00066 }

int ACE_TLI_Request_Queue::enqueue const char  device[],
int  restart,
int  rwflag
 

Definition at line 240 of file TLI_Acceptor.cpp.

References ACE_TRACE, alloc(), ACE_TLI_Request::callp_, free(), ACE_TLI_Request::handle_, ACE_TLI_Request::next_, open_new_endpoint(), and ACE_OS::t_listen().

Referenced by ACE_TLI_Acceptor::handle_async_event().

00242 {
00243   ACE_TRACE ("ACE_TLI_Request_Queue::enqueue");
00244   ACE_TLI_Request *temp = this->alloc ();
00245   ACE_TLI_Request &req  = *this->tail_;
00246   int res;
00247 
00248   do
00249     res = ACE_OS::t_listen (this->handle_, req.callp_);
00250   while (res == -1
00251          && restart
00252          && t_errno == TSYSERR
00253          && errno == EINTR);
00254 
00255   if (res != -1)
00256     {
00257       req.handle_ = open_new_endpoint (this->handle_,
00258                                        device,
00259                                        req.callp_,
00260                                        rwflag);
00261       if (req.handle_ != ACE_INVALID_HANDLE)
00262         {
00263           temp->next_ = this->tail_->next_;
00264           this->tail_->next_ = temp;
00265           this->tail_ = temp;
00266           this->current_count_++;
00267           return 0;
00268         }
00269     }
00270 
00271   // Something must have gone wrong, so free up allocated space.
00272   this->free (temp);
00273   return -1;
00274 }

void ACE_TLI_Request_Queue::free ACE_TLI_Request node  ) 
 

Definition at line 85 of file TLI_Acceptor.cpp.

References ACE_TRACE, and ACE_TLI_Request::next_.

Referenced by ACE_TLI_Acceptor::accept(), enqueue(), open(), and remove().

00086 {
00087   ACE_TRACE ("ACE_TLI_Request_Queue::free");
00088   node->next_ = this->free_list_;
00089   this->free_list_ = node;
00090 }

int ACE_TLI_Request_Queue::is_empty void   )  const
 

Definition at line 69 of file TLI_Acceptor.cpp.

References ACE_TRACE.

Referenced by ACE_TLI_Acceptor::accept().

00070 {
00071   ACE_TRACE ("ACE_TLI_Request_Queue::is_empty");
00072   return this->current_count_ == 0;
00073 }

int ACE_TLI_Request_Queue::is_full void   )  const
 

Definition at line 76 of file TLI_Acceptor.cpp.

References ACE_TRACE.

00077 {
00078   ACE_TRACE ("ACE_TLI_Request_Queue::is_full");
00079   return this->current_count_ + 1 == this->size_; // Add 1 for the dummy.
00080 }

ACE_HANDLE ACE_TLI_Request_Queue::open ACE_HANDLE  fd,
int  size
 

Definition at line 196 of file TLI_Acceptor.cpp.

References ACE_NEW_RETURN, ACE_TRACE, alloc(), ACE_TLI_Request::callp_, free(), ACE_TLI_Request::handle_, ACE_TLI_Request::next_, and ACE_OS::t_alloc().

Referenced by ACE_TLI_Acceptor::open().

00197 {
00198   ACE_TRACE ("ACE_TLI_Request_Queue::open");
00199   this->handle_   = f;
00200   this->size_ = sz + 1; // Add one more for the dummy node.
00201 
00202   ACE_NEW_RETURN (this->base_,
00203                   ACE_TLI_Request[this->size_],
00204                   ACE_INVALID_HANDLE);
00205 
00206   // Initialize the ACE_Queue and the free list.
00207 
00208   for (int i = 0; i < this->size_; i++)
00209     {
00210       ACE_TLI_Request *item = &this->base_[i];
00211       this->free (item);
00212 
00213       item->handle_ = ACE_INVALID_HANDLE;
00214       item->callp_ = (t_call *) ACE_OS::t_alloc (this->handle_,
00215                                                  T_CALL,
00216                                                  T_ALL);
00217       if (item->callp_ == 0)
00218         return ACE_INVALID_HANDLE;
00219     }
00220 
00221   this->tail_ = this->alloc ();
00222   this->tail_->next_ = this->tail_;
00223   return 0;
00224 }

int ACE_TLI_Request_Queue::remove int  sequence_number  ) 
 

Definition at line 280 of file TLI_Acceptor.cpp.

References ACE_TRACE, ACE_TLI_Request::callp_, free(), ACE_TLI_Request::next_, and ACE_OS::t_close().

Referenced by ACE_TLI_Acceptor::handle_async_event().

00281 {
00282   ACE_TRACE ("ACE_TLI_Request_Queue::remove");
00283   ACE_TLI_Request *prev = this->tail_;
00284 
00285   // Put the sequence # in the dummy node to simply the search...
00286   prev->callp_->sequence = sequence_number;
00287 
00288   ACE_TLI_Request *temp;
00289 
00290   for (temp = this->tail_->next_;
00291        temp->callp_->sequence != sequence_number;
00292        temp = temp->next_)
00293     prev = temp;
00294 
00295   if (temp == this->tail_)
00296     // Sequence # was not found, since we're back at the dummy node!
00297     return -1;
00298   else
00299     {
00300       prev->next_ = temp->next_;
00301       ACE_OS::t_close (temp->handle_);
00302       this->current_count_--;
00303       this->free (temp);
00304       return 0;
00305     }
00306 }


Member Data Documentation

ACE_TLI_Request_Queue::ACE_ALLOC_HOOK_DECLARE
 

Definition at line 46 of file TLI_Acceptor.cpp.

ACE_TLI_Request* ACE_TLI_Request_Queue::base_ [private]
 

Definition at line 53 of file TLI_Acceptor.cpp.

int ACE_TLI_Request_Queue::current_count_ [private]
 

Definition at line 52 of file TLI_Acceptor.cpp.

ACE_TLI_Request* ACE_TLI_Request_Queue::free_list_ [private]
 

Definition at line 55 of file TLI_Acceptor.cpp.

ACE_HANDLE ACE_TLI_Request_Queue::handle_ [private]
 

Definition at line 50 of file TLI_Acceptor.cpp.

int ACE_TLI_Request_Queue::size_ [private]
 

Definition at line 51 of file TLI_Acceptor.cpp.

ACE_TLI_Request* ACE_TLI_Request_Queue::tail_ [private]
 

Definition at line 54 of file TLI_Acceptor.cpp.


The documentation for this class was generated from the following file:
Generated on Thu Nov 9 11:31:38 2006 for ACE by doxygen 1.3.6