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

ACE_TLI_Request_Queue Class Reference

Collaboration diagram for ACE_TLI_Request_Queue:

Collaboration graph
[legend]
List of all members.

Public Methods

 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 223 of file TLI_Acceptor.cpp.

References ACE_TRACE.

00224   : size_ (0),
00225     current_count_ (0),
00226     base_ (0),
00227     tail_ (0),
00228     free_list_ (0)
00229 {
00230   ACE_TRACE ("ACE_TLI_Request_Queue::ACE_TLI_Request_Queue");
00231 }


Member Function Documentation

ACE_TLI_Request * ACE_TLI_Request_Queue::alloc void   
 

Definition at line 90 of file TLI_Acceptor.cpp.

References ACE_TRACE, free_list_, and ACE_TLI_Request::next_.

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

00091 {
00092   ACE_TRACE ("ACE_TLI_Request_Queue::alloc");
00093   ACE_TLI_Request *temp = this->free_list_;
00094   this->free_list_ = this->free_list_->next_;
00095   return temp;
00096 }

int ACE_TLI_Request_Queue::close void   
 

Definition at line 172 of file TLI_Acceptor.cpp.

References ACE_TRACE, base_, ACE_TLI_Request::callp_, ACE_TLI_Request::handle_, size_, and ACE_OS_TLI::t_free.

Referenced by ACE_TLI_Acceptor::close.

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

int ACE_TLI_Request_Queue::dequeue ACE_TLI_Request *&    ptr
 

Definition at line 113 of file TLI_Acceptor.cpp.

References ACE_TRACE, current_count_, ACE_TLI_Request::next_, and tail_.

Referenced by ACE_TLI_Acceptor::accept.

00114 {
00115   ACE_TRACE ("ACE_TLI_Request_Queue::dequeue");
00116   ptr = this->tail_->next_;
00117   this->tail_->next_ = ptr->next_;
00118   this->current_count_--;
00119   return 0;
00120 }

void ACE_TLI_Request_Queue::dump void    const
 

Definition at line 58 of file TLI_Acceptor.cpp.

References ACE_TRACE.

00059 {
00060   ACE_TRACE ("ACE_TLI_Request_Queue::dump");
00061 }

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

Definition at line 237 of file TLI_Acceptor.cpp.

References ACE_TRACE, alloc, ACE_TLI_Request::callp_, current_count_, free, ACE_TLI_Request::handle_, ACE_TLI_Request::next_, open_new_endpoint, ACE_OS_TLI::t_listen, and tail_.

Referenced by ACE_TLI_Acceptor::handle_async_event.

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

void ACE_TLI_Request_Queue::free ACE_TLI_Request   node
 

Definition at line 80 of file TLI_Acceptor.cpp.

References ACE_TRACE, free_list_, and ACE_TLI_Request::next_.

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

00081 {
00082   ACE_TRACE ("ACE_TLI_Request_Queue::free");
00083   node->next_ = this->free_list_;
00084   this->free_list_ = node;
00085 }

int ACE_TLI_Request_Queue::is_empty void    const
 

Definition at line 64 of file TLI_Acceptor.cpp.

References ACE_TRACE, and current_count_.

Referenced by ACE_TLI_Acceptor::accept.

00065 {
00066   ACE_TRACE ("ACE_TLI_Request_Queue::is_empty");
00067   return this->current_count_ == 0;
00068 }

int ACE_TLI_Request_Queue::is_full void    const
 

Definition at line 71 of file TLI_Acceptor.cpp.

References ACE_TRACE, current_count_, and size_.

00072 {
00073   ACE_TRACE ("ACE_TLI_Request_Queue::is_full");
00074   return this->current_count_ + 1 == this->size_; // Add 1 for the dummy.
00075 }

ACE_HANDLE ACE_TLI_Request_Queue::open ACE_HANDLE    fd,
int    size
 

Definition at line 193 of file TLI_Acceptor.cpp.

References ACE_NEW_RETURN, ACE_TRACE, alloc, base_, ACE_TLI_Request::callp_, free, ACE_TLI_Request::handle_, handle_, ACE_TLI_Request::next_, size_, ACE_OS_TLI::t_alloc, and tail_.

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

int ACE_TLI_Request_Queue::remove int    sequence_number
 

Definition at line 277 of file TLI_Acceptor.cpp.

References ACE_TRACE, ACE_TLI_Request::callp_, current_count_, free, ACE_TLI_Request::handle_, ACE_TLI_Request::next_, ACE_OS_TLI::t_close, and tail_.

Referenced by ACE_TLI_Acceptor::handle_async_event.

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


Member Data Documentation

ACE_TLI_Request_Queue::ACE_ALLOC_HOOK_DECLARE
 

Definition at line 43 of file TLI_Acceptor.cpp.

ACE_TLI_Request* ACE_TLI_Request_Queue::base_ [private]
 

Definition at line 50 of file TLI_Acceptor.cpp.

Referenced by close, and open.

int ACE_TLI_Request_Queue::current_count_ [private]
 

Definition at line 49 of file TLI_Acceptor.cpp.

Referenced by dequeue, enqueue, is_empty, is_full, and remove.

ACE_TLI_Request* ACE_TLI_Request_Queue::free_list_ [private]
 

Definition at line 52 of file TLI_Acceptor.cpp.

Referenced by alloc, and free.

ACE_HANDLE ACE_TLI_Request_Queue::handle_ [private]
 

Definition at line 47 of file TLI_Acceptor.cpp.

Referenced by open.

int ACE_TLI_Request_Queue::size_ [private]
 

Definition at line 48 of file TLI_Acceptor.cpp.

Referenced by close, is_full, and open.

ACE_TLI_Request* ACE_TLI_Request_Queue::tail_ [private]
 

Definition at line 51 of file TLI_Acceptor.cpp.

Referenced by dequeue, enqueue, open, and remove.


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