NAME
ACE_Locked_Free_List - Implements a free list.
SYNOPSIS
#include <ace/Free_List.h>
template<class T, class ACE_LOCK>
class ACE_Locked_Free_List : public ACE_Free_List<T>
{
public:
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
);
virtual ~ACE_Locked_Free_List (void);
virtual void add (T *element);
virtual T *remove (void);
virtual size_t size (void);
virtual void resize (size_t newsize);
protected:
virtual void alloc (size_t n);
virtual void dealloc (size_t n);
int mode_;
T *free_list_;
size_t lwm_;
size_t hwm_;
size_t inc_;
size_t size_;
ACE_LOCK mutex_;
private:
inline ACE_UNIMPLEMENTED_FUNC (
ACE_Locked_Free_List (const ACE_Locked_Free_List<T, ACE_LOCK> &)
);
};
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 .
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
);
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.
virtual ~ACE_Locked_Free_List (void);
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).
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.
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.
Don't allow these operations for now.
inline ACE_UNIMPLEMENTED_FUNC (
ACE_Locked_Free_List (const ACE_Locked_Free_List<T, ACE_LOCK> &)
);
AUTHOR
Darrell Brunsch ([email protected])
LIBRARY
ace