diff options
author | Steve Huston <shuston@riverace.com> | 2004-09-14 15:33:15 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2004-09-14 15:33:15 +0000 |
commit | 66af969f5cb68894d6f7167f4115db2c5bb97bcc (patch) | |
tree | 4a30cd9314adb3d8a1b6b2cd1c7b8e8b083b51d0 | |
parent | 3ab8cfa07d7235a304a11d1691f583a5ae93c6e6 (diff) | |
download | ATCD-66af969f5cb68894d6f7167f4115db2c5bb97bcc.tar.gz |
ChangeLogTag:Tue Sep 14 11:07:25 2004 Steve Huston <shuston@riverace.com>
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | ace/Malloc_T.h | 6 | ||||
-rw-r--r-- | ace/Malloc_T.inl | 12 | ||||
-rw-r--r-- | tests/Cached_Allocator_Test.cpp | 19 |
5 files changed, 50 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index 42905a998bd..87febced38d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Sep 14 11:07:25 2004 Steve Huston <shuston@riverace.com> + + * ace/Malloc_T.{h inl}: Added ACE_Cached_Allocator<>::pool_depth() + and ACE_Dynamic_Cached_Allocator<>::pool_depth(). Each returns the + number of items in the cache available for allocating. Thank you to + Jeff Jones <jjones@zonetrading.com> for this addition. + + * tests/Cached_Allocator_Test.cpp: Added tests of the new pool_depth() + method. + + * THANKS: Added Jeff Jones to the Hall of Fame. + Tue Sep 14 11:58:12 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl> * ace/Dynamic_Service.h: @@ -1904,6 +1904,7 @@ Rick Robinson <rick at oyarsa dot com> John D. Robertson <john at rrci dot com> Paul Lew <paullew at cisco dot com> Eider Oliveira <eider at oliveira dot gmail at com> +Jeff Jones <jjones at zonetrading dot com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson in the early 1990's. Paul devised the recursive Makefile diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index ada5fc23236..db31b148fa3 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -115,6 +115,9 @@ public: /// Return a chunk of memory back to free list cache. void free (void *); + /// Return the number of chunks available in the cache. + size_t pool_depth (void); + private: /// Remember how we allocate the memory in the first place so /// we can clear things up later. @@ -177,6 +180,9 @@ public: /// Return a chunk of memory back to free list cache. void free (void *); + /// Return the number of chunks available in the cache. + size_t pool_depth (void); + private: /// Remember how we allocate the memory in the first place so /// we can clear things up later. diff --git a/ace/Malloc_T.inl b/ace/Malloc_T.inl index b24436fb868..109d1153336 100644 --- a/ace/Malloc_T.inl +++ b/ace/Malloc_T.inl @@ -67,6 +67,12 @@ ACE_Cached_Allocator<T, ACE_LOCK>::free (void * ptr) this->free_list_.add ((ACE_Cached_Mem_Pool_Node<T> *) ptr) ; } +template <class T, class ACE_LOCK> ACE_INLINE size_t +ACE_Cached_Allocator<T, ACE_LOCK>::pool_depth (void) +{ + return this->free_list_.size (); +} + template <class ACE_LOCK> ACE_INLINE void * ACE_Dynamic_Cached_Allocator<ACE_LOCK>::malloc (size_t nbytes) { @@ -107,6 +113,12 @@ ACE_Dynamic_Cached_Allocator<ACE_LOCK>::free (void * ptr) this->free_list_.add ((ACE_Cached_Mem_Pool_Node<char> *) ptr); } +template <class ACE_LOCK> ACE_INLINE size_t +ACE_Dynamic_Cached_Allocator<ACE_LOCK>::pool_depth (void) +{ + return this->free_list_.size (); +} + template <class MALLOC> ACE_INLINE void * ACE_Allocator_Adapter<MALLOC>::malloc (size_t nbytes) { diff --git a/tests/Cached_Allocator_Test.cpp b/tests/Cached_Allocator_Test.cpp index 0e5bcf5f28f..78cab3e70e4 100644 --- a/tests/Cached_Allocator_Test.cpp +++ b/tests/Cached_Allocator_Test.cpp @@ -149,6 +149,7 @@ run_main (int argc, ACE_TCHAR *argv[]) size_t chunk_size = 0; size_t n_chunks = 0; size_t requested_size = 0; + size_t depth = 0; char *ptr1 = 0; char *ptr2 = 0; char *ptr3 = 0; @@ -174,6 +175,12 @@ run_main (int argc, ACE_TCHAR *argv[]) DYNAMIC_ALLOCATOR allocator (n_chunks, chunk_size); + if ((depth = allocator.pool_depth ()) != n_chunks) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Expected pool depth ") ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT (" but reported ") ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT ("\n"), + n_chunks, depth)); requested_size = chunk_size; ACE_DEBUG ((LM_INFO, ACE_TEXT (" (%t) Allocating chunk 1: %d bytes, should succeed...\n"), @@ -184,6 +191,12 @@ run_main (int argc, ACE_TCHAR *argv[]) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%t) Failed, exiting.\n")), -1); ACE_DEBUG ((LM_INFO, ACE_TEXT (" (%t) OK, succeeded.\n"))); + if ((depth = allocator.pool_depth ()) != (n_chunks - 1)) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Expected pool depth ") ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT (" but reported ") ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT ("\n"), + n_chunks - 1, depth)); requested_size = chunk_size + 1; ACE_DEBUG ((LM_INFO, @@ -208,6 +221,12 @@ run_main (int argc, ACE_TCHAR *argv[]) ACE_DEBUG ((LM_INFO, ACE_TEXT (" (%t) OK, succeeded.\n"))); // One chunk too far... + if ((depth = allocator.pool_depth ()) != 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Expected pool depth 0") + ACE_TEXT (" but reported ") ACE_SIZE_T_FORMAT_SPECIFIER + ACE_TEXT ("\n"), + depth)); requested_size = chunk_size; ACE_DEBUG ((LM_INFO, ACE_TEXT (" (%t) Allocating chunk 4: %d bytes, no free chunks,") |