diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-13 14:08:02 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-13 14:08:02 +0000 |
commit | 8735fc47de4e0f11284ad0ab5255cb897b6a8fcb (patch) | |
tree | 792853187330aaecaa4825a1d66202138e41d7e3 /ace/Free_List.h | |
parent | cf33e17fe1575ae56a0a697ad92836b1bf7fe4a2 (diff) | |
download | ATCD-8735fc47de4e0f11284ad0ab5255cb897b6a8fcb.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace/Free_List.h')
-rw-r--r-- | ace/Free_List.h | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/ace/Free_List.h b/ace/Free_List.h index 7e6fc07d67d..9a44f6ef8c7 100644 --- a/ace/Free_List.h +++ b/ace/Free_List.h @@ -19,47 +19,37 @@ #include "ace/OS.h" #include "ace/Synch_T.h" -enum ACE_Free_List_Op_Mode -{ - ACE_FREE_LIST_WITH_POOL, - ACE_PURE_FREE_LIST -}; -// Free list operation mode, -// ACE_FREE_LIST_WITH_POOL: A free list which create more elements when -// there aren't enough elements. -// ACE_PURE_FREE_LIST: A simple free list which doen't allocate/deallocate -// elements. - template <class T> class ACE_Free_List // = TITLE - // Implements a free list + // Implements a free list. // // = DESCRIPTION // This class maintains a free list of nodes of type T. { public: virtual ~ACE_Free_List (void); - // Destructor - removes all the elements from the free_list + // Destructor - removes all the elements from the free_list. virtual void add (T *element) = 0; - // Inserts an element onto the free list (if it isn't past the high water mark) + // Inserts an element onto the free list (if it isn't past the high + // water mark). virtual T *remove (void) = 0; - // Takes a element off the freelist and returns it. It creates <inc> new elements - // if the size is at or below the low water mark. + // Takes a element off the freelist and returns it. It creates + // <inc> new elements if the size is at or below the low water mark. - virtual size_t size () = 0; - // Returns the current size of the free list + virtual size_t size (void) = 0; + // Returns the current size of the free list. virtual void resize (size_t newsize) = 0; - // Resizes the free list to <newsize> + // Resizes the free list to <newsize>. }; template <class T, class LOCK> class ACE_Locked_Free_List : public ACE_Free_List<T> // = TITLE - // Implements a free list + // Implements a free list. // // = DESCRIPTION // This class maintains a free list of nodes of type T. It depends on @@ -67,37 +57,43 @@ class ACE_Locked_Free_List : public ACE_Free_List<T> // a mutex so the freelist can be used in a multithreaded program . { public: - - ACE_Locked_Free_List (ACE_Free_List_Op_Mode mode = ACE_FREE_LIST_WITH_POOL, + // = Initialization and termination. + ACE_Locked_Free_List (int mode = ACE_FREE_LIST_WITH_POOL, size_t prealloc = ACE_DEFAULT_FREE_LIST_PREALLOC, size_t lwm = ACE_DEFAULT_FREE_LIST_LWM, size_t hwm = ACE_DEFAULT_FREE_LIST_HWM, size_t inc = ACE_DEFAULT_FREE_LIST_INC, LOCK *mutex = 0); - // Default constructor that takes in a preallocation number (<prealloc>), a - // low and high water mark (<lwm> and <hwm>) and an increment value (<inc>) + // Constructor takes a <mode> (i.e., ACE_FREE_LIST_WITH_POOL or + // ACE_PURE_FREE_LIST), a count of the number of nodes to + // <prealloc>, a low and high water mark (<lwm> and <hwm>) that + // indicate when to allocate more nodes, an increment value (<inc>) + // that indicates how many nodes to allocate when the list must + // grow, and a pointer to a <mutex> that is used to determine the + // synchronization properties of the free list. virtual ~ACE_Locked_Free_List (void); - // Destructor - removes all the elements from the free_list + // Destructor - removes all the elements from the free_list. virtual void add (T *element); - // Inserts an element onto the free list (if it isn't past the high water mark) + // Inserts an element onto the free list (if it isn't past the high + // water mark). virtual T *remove (void); - // Takes a element off the freelist and returns it. It creates <inc> new elements - // if the size is at or below the low water mark. + // Takes a element off the freelist and returns it. It creates + // <inc> new elements if the size is at or below the low water mark. - virtual size_t size (); - // Returns the current size of the free list + virtual size_t size (void); + // Returns the current size of the free list. virtual void resize (size_t newsize); // Resizes the free list to <newsize> LOCK &get_mutex (void); - // Returns a reference to the mutex + // Returns a reference to the mutex. void set_mutex (LOCK &mutex); - // Sets the mutex to <mutex> + // Sets the mutex to <mutex>. protected: virtual void alloc (size_t n); @@ -106,8 +102,9 @@ protected: virtual void dealloc (size_t n); // Removes and frees <n> nodes from the freelist - ACE_Free_List_Op_Mode mode_; - // Free list operation mode, see enum declaration above. + int mode_; + // Free list operation mode, either ACE_FREE_LIST_WITH_POOL or + // ACE_PURE_FREE_LIST. T *free_list_; // Pointer to the first node in the freelist @@ -116,19 +113,19 @@ protected: // Low water mark size_t hwm_; - // High water mark + // High water mark. size_t inc_; - // Increment value + // Increment value. size_t size_; - // Keeps track of the size of the list + // Keeps track of the size of the list. LOCK *mutex_; // Synchronization variable for <ACE_Timer_Queue>. int delete_mutex_; - // flag to remember ownership of the mutex + // flag to remember ownership of the mutex. private: // = Don't allow these operations for now. |