List Info

Thread: CR-Client: add CHXBufferPoolManager to common/util




CR-Client: add CHXBufferPoolManager to common/util
country flaguser name
United States
2007-04-12 12:13:10
Description
------------------------------------
This change adds a new class called CHXBufferPoolManager
to common/util. This class is similar to the other 
buffer pool classes in that it maintains a pool of
buffers and by re-using these buffers, allows the
user to limit the number of calls to the OS to actually
allocate memory. These kinds of classes are useful
in applications when lots of similar-sized buffers are
used (for instance, buffers for audio packets or frame
buffers for video).

The feature that distinguishes this buffer pool class
from other buffer pool implementations is its simplicity
of use. For most buffer pool implementations, the user
has to make one call to the class to *get* a buffer
and when the user is done with the buffer, then you
usually have to make *another* call to the class to
return the buffer to the pool. This makes them difficult
to use for applications like packetization where buffers
are created in one component and then passed through
several
other components before finishing.

In CHXBufferPoolManager, you simply call:

GetBufferFromPool(UINT32 ulSize, REF(IHXBuffer*) rpBuffer)

and you get back an IHXBuffer of the size you requested.
When you finish with the buffer, you simply release it
as usual - no need to make a call back to the manager
to put the buffer back into the pool. It's also no problem
if the buffer pool manager goes away before all the buffers
it created go away.

This is implemented internally by having a wrapper class
which implements IHXBuffer. The wrapper class holds
an internal IHXBuffer and also has a pointer back to the
CHXBufferPoolManager. when the wrapper IHXBuffer's refcount
goes to zero, the internal IHXBuffer is then returned
to the pool of buffers in CHXBufferPoolManager.

Files Added
-----------------------------------------
common/container/hxbufferpool.cpp
common/container/pub/hxbufferpool.h

Files Modified
-----------------------------------------
common/container/ucontlib

Branches
-----------------------------------------
HEAD only

Index: ucontlib
============================================================
=======
RCS file: /cvsroot/common/container/ucontlib,v
retrieving revision 1.16
diff -u -w -u -w -r1.16 ucontlib
--- ucontlib    11 Jan 2007 21:45:04 -0000      1.16
+++ ucontlib    12 Apr 2007 17:11:24 -0000
 -55,7
+55,8 
                     "../dbgtool/pub",
                     "../runtime/pub",
                     "../util/pub",
-                    "../system/pub")
+                    "../system/pub",
+                    "../log/logutil/pub")

 project.AddSources("carray.cpp",
                    "hxslist.cpp",
 -87,7
+88,8 
                    "hxlist.cpp",
                    "hxlistp.cpp",
                    "dict.cpp",
-                  "unkimp.cpp")
+                   "unkimp.cpp",
+                   "hxbufferpool.cpp")

 if "HELIX_FEATURE_USE_NULL_STATIC_BUFFER" in
project.defines:
        project.AddSources("hxsbuffer_null.cpp")


=============================================
Eric Hyche (ehychereal.com)
Technical Lead
RealNetworks, Inc. 

_______________________________________________
Common-dev mailing list
Common-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/comm
on-dev

  
  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )