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