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

Handle_Gobbler.i

Go to the documentation of this file.
00001 // $Id: Handle_Gobbler.i,v 1.1.1.2 2001/12/04 14:33:01 chad Exp $
00002 
00003 // Since this is only included in Handle_Gobbler.h, these should be
00004 // inline, not ACE_INLINE.
00005 // FUZZ: disable check_for_inline
00006 
00007 inline void
00008 ACE_Handle_Gobbler::close_remaining_handles (void)
00009 {
00010   HANDLE_SET::iterator iterator =
00011     this->handle_set_.begin ();
00012 
00013   HANDLE_SET::iterator end =
00014     this->handle_set_.end ();
00015 
00016   for (;
00017        iterator != end;
00018        ++iterator)
00019     {
00020       ACE_OS::close (*iterator);
00021     }
00022 }
00023 
00024 inline
00025 ACE_Handle_Gobbler::~ACE_Handle_Gobbler (void)
00026 {
00027   this->close_remaining_handles ();
00028 }
00029 
00030 inline int
00031 ACE_Handle_Gobbler::free_handles (size_t n_handles)
00032 {
00033   HANDLE_SET::iterator iterator =
00034     this->handle_set_.begin ();
00035 
00036   HANDLE_SET::iterator end =
00037     this->handle_set_.end ();
00038 
00039   for (;
00040        iterator != end && n_handles > 0;
00041        ++iterator, --n_handles)
00042     {
00043       int result = ACE_OS::close (*iterator);
00044       if (result != 0)
00045         return result;
00046     }
00047 
00048   return 0;
00049 }
00050 
00051 inline int
00052 ACE_Handle_Gobbler::consume_handles (size_t n_handles_to_keep_available)
00053 {
00054   int result = 0;
00055 
00056 #if defined(ACE_WIN32)
00057   // On Win32, this style of gobbling doesn't seem to work.
00058   ACE_UNUSED_ARG(n_handles_to_keep_available);
00059 
00060 #else
00061 
00062   while (1)
00063     {
00064       ACE_HANDLE handle = ACE_OS::open (ACE_DEV_NULL, O_WRONLY);
00065 
00066       if (handle == ACE_INVALID_HANDLE)
00067         {
00068           if (ACE::out_of_handles (errno))
00069             {
00070               result = this->free_handles (n_handles_to_keep_available);
00071               break;
00072             }
00073           else
00074             {
00075               result = -1;
00076               break;
00077             }
00078         }
00079 
00080       result = this->handle_set_.insert (handle);
00081       if (result == -1)
00082         break;
00083     }
00084 
00085 #endif /* ACE_WIN32 */
00086 
00087   return result;
00088 }

Generated on Mon Jun 16 11:19:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002