Handle_Gobbler.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Handle_Gobbler.h
00006  *
00007  *  Handle_Gobbler.h,v 1.12 2006/02/10 09:53:39 jwillemsen Exp
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/Unbounded_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 
00058   typedef ACE_Unbounded_Set<ACE_HANDLE> HANDLE_SET;
00059 
00060   /// The container which holds the open descriptors.
00061   HANDLE_SET handle_set_;
00062 };
00063 
00064 ACE_END_VERSIONED_NAMESPACE_DECL
00065 
00066 #include "ace/Handle_Gobbler.inl"
00067 
00068 #include /**/ "ace/post.h"
00069 #endif /* ACE_HANDLE_GOBBLER_H */

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6