summaryrefslogtreecommitdiff
path: root/ace/Free_List.h
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Free_List.h')
-rw-r--r--ace/Free_List.h119
1 files changed, 61 insertions, 58 deletions
diff --git a/ace/Free_List.h b/ace/Free_List.h
index 41650439d1c..dbde47da788 100644
--- a/ace/Free_List.h
+++ b/ace/Free_List.h
@@ -1,19 +1,16 @@
/* -*- C++ -*- */
-// $Id$
-
-
-// ============================================================================
-//
-// = LIBRARY
-// ace
-//
-// = FILENAME
-// Free_List.h
-//
-// = AUTHOR
-// Darrell Brunsch (brunsch@cs.wustl.edu)
-//
-// ============================================================================
+
+
+//=============================================================================
+/**
+ * @file Free_List.h
+ *
+ * $Id$
+ *
+ * @author Darrell Brunsch (brunsch@cs.wustl.edu)
+ */
+//=============================================================================
+
#ifndef ACE_FREE_LIST_H
#define ACE_FREE_LIST_H
@@ -27,103 +24,109 @@
#include "ace/Synch_T.h"
+/**
+ * @class ACE_Free_List
+ *
+ * @brief Implements a free list.
+ *
+ * This class maintains a free list of nodes of type T.
+ */
template <class T>
class ACE_Free_List
{
- // = TITLE
- // Implements a free list.
- //
- // = DESCRIPTION
- // This class maintains a free list of nodes of type T.
public:
+ /// Destructor - removes all the elements from the free_list.
virtual ~ACE_Free_List (void);
- // Destructor - removes all the elements from the free_list.
+ /// Inserts an element onto the free list (if it isn't past the high
+ /// water mark).
virtual void add (T *element) = 0;
- // Inserts an element onto the free list (if it isn't past the high
- // 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 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.
+ /// Returns the current size of the free list.
virtual size_t size (void) = 0;
- // Returns the current size of the free list.
+ /// Resizes the free list to <newsize>.
virtual void resize (size_t newsize) = 0;
- // Resizes the free list to <newsize>.
};
+/**
+ * @class ACE_Locked_Free_List
+ *
+ * @brief Implements a free list.
+ *
+ * This class maintains a free list of nodes of type T. It
+ * depends on the type T having a <get_next> and <set_next>
+ * method. It maintains a mutex so the freelist can be used in
+ * a multithreaded program .
+ */
template <class T, class ACE_LOCK>
class ACE_Locked_Free_List : public ACE_Free_List<T>
{
- // = TITLE
- // Implements a free list.
- //
- // = DESCRIPTION
- // This class maintains a free list of nodes of type T. It
- // depends on the type T having a <get_next> and <set_next>
- // method. It maintains a mutex so the freelist can be used in
- // a multithreaded program .
public:
// = Initialization and termination.
+ /**
+ * 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.
+ */
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);
- // 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.
+ /// Destructor - removes all the elements from the free_list.
virtual ~ACE_Locked_Free_List (void);
- // Destructor - removes all the elements from the free_list.
+ /// Inserts an element onto the free list (if it isn't past the high
+ /// water mark).
virtual void add (T *element);
- // Inserts an element onto the free list (if it isn't past the high
- // 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 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.
+ /// Returns the current size of the free list.
virtual size_t size (void);
- // Returns the current size of the free list.
+ /// Resizes the free list to <newsize>.
virtual void resize (size_t newsize);
- // Resizes the free list to <newsize>.
protected:
+ /// Allocates <n> extra nodes for the freelist.
virtual void alloc (size_t n);
- // Allocates <n> extra nodes for the freelist.
+ /// Removes and frees <n> nodes from the freelist.
virtual void dealloc (size_t n);
- // Removes and frees <n> nodes from the freelist.
+ /// Free list operation mode, either ACE_FREE_LIST_WITH_POOL or
+ /// ACE_PURE_FREE_LIST.
int mode_;
- // Free list operation mode, either ACE_FREE_LIST_WITH_POOL or
- // ACE_PURE_FREE_LIST.
+ /// Pointer to the first node in the freelist.
T *free_list_;
- // Pointer to the first node in the freelist.
+ /// Low water mark.
size_t lwm_;
- // Low water mark.
+ /// High water mark.
size_t hwm_;
- // High water mark.
+ /// Increment value.
size_t inc_;
- // Increment value.
+ /// Keeps track of the size of the list.
size_t size_;
- // Keeps track of the size of the list.
+ /// Synchronization variable for <ACE_Timer_Queue>.
ACE_LOCK mutex_;
- // Synchronization variable for <ACE_Timer_Queue>.
private:
// = Don't allow these operations for now.