diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-13 05:14:27 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-13 05:14:27 +0000 |
commit | 67fe97bbe3806d256f63d914c02bbbb3e62b46b4 (patch) | |
tree | 18a41a1404358c94f5181f0e3b535d0f3299d459 /ace/Free_List.i | |
parent | 98a1a1c8af41319e3141e9668d9b0097cefd34fd (diff) | |
download | ATCD-67fe97bbe3806d256f63d914c02bbbb3e62b46b4.tar.gz |
Removed ACE_Locked_Simple_Free_List.
Diffstat (limited to 'ace/Free_List.i')
-rw-r--r-- | ace/Free_List.i | 74 |
1 files changed, 24 insertions, 50 deletions
diff --git a/ace/Free_List.i b/ace/Free_List.i index d39e392cf25..e808df608c5 100644 --- a/ace/Free_List.i +++ b/ace/Free_List.i @@ -1,47 +1,15 @@ /* -*- C++ -*- */ -// Inserts an element onto the free list (if it isn't past the high water mark) - -template <class T, class LOCK> ACE_INLINE T * -ACE_Locked_Simple_Free_List<T, LOCK>::remove (void) -{ - ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, NULL)); - T *retv = this->head_; - - if (retv != 0) - { - this->head_ = retv->get_next (); - this->size_--; - } - return retv; -} - -template <class T, class LOCK> ACE_INLINE void -ACE_Locked_Simple_Free_List<T, LOCK>::add (T *mem) -{ - ACE_MT (ACE_GUARD (LOCK, ace_mon, this->lock_)); - mem->set_next (this->head_); - this->head_ = mem; - this->size_++; -} - -template <class T, class LOCK> ACE_INLINE size_t -ACE_Locked_Simple_Free_List<T, LOCK>::size (void) -{ - return this->size_; -} - -template <class T, class LOCK> ACE_INLINE void -ACE_Locked_Simple_Free_List<T, LOCK>::resize (size_t) -{ -} +// Inserts an element onto the free list (if we are allowed to manage +// elements withing and it pasts the high water mark, delete the +// element) template <class T, class LOCK> ACE_INLINE void ACE_Locked_Free_List<T, LOCK>::add (T *element) { ACE_MT (ACE_GUARD (LOCK, ace_mon, *this->mutex_)); // Check to see that we not at the high water mark - if (this->size_ >= this->hwm_) + if (this->mode_ == ACE_PURE_FREE_LIST || this->size_ >= this->hwm_) { element->set_next (this->free_list_); this->free_list_ = element; @@ -52,24 +20,27 @@ ACE_Locked_Free_List<T, LOCK>::add (T *element) } -// Takes a element off the freelist and returns it. It creates <inc> new elements -// if the size is at the low water mark. +// Takes a element off the freelist and returns it. It creates <inc> +// new elements if we are allowed to do it and the size is at the low +// water mark. -template <class T, class LOCK> ACE_INLINE T * +template <class T, class LOCK> ACE_INLINE T* ACE_Locked_Free_List<T, LOCK>::remove (void) { ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, *this->mutex_, 0)); - T *temp; // If we are at the low water mark, add some nodes - if (this->size_ <= this->lwm_) + if (this->mode_ != ACE_PURE_FREE_LIST && this->size_ <= this->lwm_) this->alloc (this->inc_); // Remove a node - temp = this->free_list_; - this->free_list_ = this->free_list_->get_next (); - this->size_--; - + T *temp = this->free_list_; + if (temp != 0) + { + this->free_list_ = this->free_list_->get_next (); + this->size_--; + } + return temp; } @@ -89,11 +60,14 @@ template <class T, class LOCK> ACE_INLINE void ACE_Locked_Free_List<T, LOCK>::resize (size_t newsize) { ACE_MT (ACE_GUARD (LOCK, ace_mon, *this->mutex_)); - // Check to see if we grow or shrink - if (newsize < this->size_) - this->dealloc (this->size_ - newsize); - else - this->alloc (newsize - this->size_); + + // Check if we are allowed to resize + if (this->mode_ != ACE_PURE_FREE_LIST) + // Check to see if we grow or shrink + if (newsize < this->size_) + this->dealloc (this->size_ - newsize); + else + this->alloc (newsize - this->size_); } |