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

Handle_Gobbler.h

Go to the documentation of this file.
00001 
00002 //=============================================================================
00003 /**
00004  *  @file    Handle_Gobbler.h
00005  *
00006  *  $Id: Handle_Gobbler.h,v 1.1.1.3 2001/12/04 14:33:01 chad Exp $
00007  *
00008  *  @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
00009  *  @author Irfan Pyarali <irfan@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_HANDLE_GOBBLER_H
00015 #define ACE_HANDLE_GOBBLER_H
00016 #include "ace/pre.h"
00017 
00018 #include "ace/OS.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "ace/Unbounded_Set.h"
00025 
00026 /**
00027  * @class ACE_Handle_Gobbler
00028  *
00029  * @brief This class gobbles up handles.
00030  *
00031  * This is useful when we need to control the number of handles
00032  * available for a process.  This class is mostly used for
00033  * testing purposes.
00034  */
00035 class ACE_Handle_Gobbler
00036 {
00037 public:
00038 
00039   /// Destructor.  Cleans up any remaining handles.
00040   inline ~ACE_Handle_Gobbler (void);
00041 
00042   /**
00043    * Handles are opened continously until the process runs out of
00044    * them, and then <n_handles_to_keep_available> handles are closed
00045    * (freed) thereby making them usable in the future.
00046    */
00047   inline int consume_handles (size_t n_handles_to_keep_available);
00048 
00049   /// Free up <n_handles>.
00050   inline int free_handles (size_t n_handles);
00051 
00052   /// All remaining handles are closed.
00053   inline void close_remaining_handles (void);
00054 
00055 private:
00056 
00057   typedef ACE_Unbounded_Set<ACE_HANDLE> HANDLE_SET;
00058 
00059   /// The container which holds the open descriptors.
00060   HANDLE_SET handle_set_;
00061 };
00062 
00063 #include "ace/Handle_Gobbler.i"
00064 
00065 #include "ace/post.h"
00066 #endif /* ACE_HANDLE_GOBBLER_H */

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