00001
00002
00003
00004
00005
00006
00007
00008
00009 template <class T, class ACE_LOCK> ACE_INLINE void
00010 ACE_Locked_Free_List<T, ACE_LOCK>::add (T *element)
00011 {
00012 ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
00013
00014
00015 if (this->mode_ == ACE_PURE_FREE_LIST
00016 || this->size_ < this->hwm_)
00017 {
00018 element->set_next (this->free_list_);
00019 this->free_list_ = element;
00020 this->size_++;
00021 }
00022 else
00023 delete element;
00024 }
00025
00026
00027
00028
00029
00030 template <class T, class ACE_LOCK> ACE_INLINE T *
00031 ACE_Locked_Free_List<T, ACE_LOCK>::remove (void)
00032 {
00033 ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, 0));
00034
00035
00036 if (this->mode_ != ACE_PURE_FREE_LIST && this->size_ <= this->lwm_)
00037 this->alloc (this->inc_);
00038
00039
00040 T *temp = this->free_list_;
00041
00042 if (temp != 0)
00043 {
00044 this->free_list_ = this->free_list_->get_next ();
00045 this->size_--;
00046 }
00047
00048 return temp;
00049 }
00050
00051
00052
00053
00054 template <class T, class ACE_LOCK> ACE_INLINE size_t
00055 ACE_Locked_Free_List<T, ACE_LOCK>::size (void)
00056 {
00057 return this->size_;
00058 }
00059
00060
00061
00062 template <class T, class ACE_LOCK> ACE_INLINE void
00063 ACE_Locked_Free_List<T, ACE_LOCK>::resize (size_t newsize)
00064 {
00065 ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
00066
00067
00068 if (this->mode_ != ACE_PURE_FREE_LIST)
00069
00070 if (newsize < this->size_)
00071 this->dealloc (this->size_ - newsize);
00072 else
00073 this->alloc (newsize - this->size_);
00074 }
00075
00076