summaryrefslogtreecommitdiff
path: root/ace/PI_Malloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'ace/PI_Malloc.h')
-rw-r--r--ace/PI_Malloc.h126
1 files changed, 67 insertions, 59 deletions
diff --git a/ace/PI_Malloc.h b/ace/PI_Malloc.h
index ed3ed9ba702..60981cd84e3 100644
--- a/ace/PI_Malloc.h
+++ b/ace/PI_Malloc.h
@@ -1,13 +1,14 @@
-// $Id$
-
-// ==========================================================================
-// FILENAME
-// PI_Malloc.h
-//
-// AUTHOR
-// Priyanka Gontla <pgontla@ece.uci.edu>
-//
-// ==========================================================================
+
+//=============================================================================
+/**
+ * @file PI_Malloc.h
+ *
+ * $Id$
+ *
+ * @author Priyanka Gontla <pgontla@ece.uci.edu>
+ */
+//=============================================================================
+
#ifndef ACE_PI_MALLOC_H
#define ACE_PI_MALLOC_H
#include "ace/pre.h"
@@ -33,21 +34,21 @@
#endif /* ACE_HAS_THREADS */
typedef ACE_Atomic_Op<ACE_PROCESS_MUTEX, int> ACE_INT;
+
+/// This keeps stats on the usage of the memory manager.
struct ACE_Export ACE_Malloc_Stats
-// TITLE
-// This keeps stats on the usage of the memory manager.
{
ACE_Malloc_Stats (void);
void dump (void) const;
+ /// Coarse-grained unit of allocation.
ACE_INT nchunks_;
- // Coarse-grained unit of allocation.
+ /// Fine-grained unit of allocation.
ACE_INT nblocks_;
- // Fine-grained unit of allocation.
+ /// Number of blocks in use
ACE_INT ninuse_;
- // Number of blocks in use
};
#define ACE_MALLOC_STATS(X) X
#else
@@ -80,17 +81,19 @@ struct ACE_Export ACE_Malloc_Stats
#if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
// prepare for position independent malloc
+/**
+ * @class ACE_PI_Control_Block
+ *
+ * @brief This information is stored in memory allocated by the <Memory_Pool>.
+ *
+ * This class implements the control block structure that can be
+ * used in a "position indepent" fashion, i.e., you don't need to
+ * "map" the underlying memory pool to the same address in
+ * processes sharing the memory. The tradoff of this flexibility
+ * is more expensive malloc/free operations.
+ */
class ACE_Export ACE_PI_Control_Block
{
- // = TITLE
- // This information is stored in memory allocated by the <Memory_Pool>.
- //
- // = DESCRIPTION
- // This class implements the control block structure that can be
- // used in a "position indepent" fashion, i.e., you don't need to
- // "map" the underlying memory pool to the same address in
- // processes sharing the memory. The tradoff of this flexibility
- // is more expensive malloc/free operations.
public:
class ACE_Malloc_Header;
class ACE_Name_Node;
@@ -99,25 +102,28 @@ public:
typedef ACE_Based_Pointer<ACE_Name_Node> NAME_NODE_PTR;
typedef ACE_Based_Pointer_Basic<char> CHAR_PTR;
+ /**
+ * @class ACE_Malloc_Header
+ *
+ * @brief This is the control block header. It's used by <ACE_Malloc>
+ * to keep track of each chunk of data when it's in the free
+ * list or in use.
+ */
class ACE_Export ACE_Malloc_Header
{
- // = TITLE
- // This is the control block header. It's used by <ACE_Malloc>
- // to keep track of each chunk of data when it's in the free
- // list or in use.
public:
ACE_Malloc_Header (void);
+ /// Points to next block if on free list.
MALLOC_HEADER_PTR next_block_;
- // Points to next block if on free list.
+ /// Initialize a malloc header pointer.
static void init_ptr (MALLOC_HEADER_PTR *ptr,
ACE_Malloc_Header *init,
void *base_addr);
- // Initialize a malloc header pointer.
+ /// Size of this header control block.
size_t size_;
- // Size of this header control block.
#if defined (ACE_PI_MALLOC_PADDING_SIZE) && (ACE_PI_MALLOC_PADDING_SIZE == 0)
// No padding required for PI_Malloc_Header.
@@ -130,81 +136,83 @@ public:
long padding_[ACE_PI_MALLOC_PADDING_SIZE < 1 ? 1 : ACE_PI_MALLOC_PADDING_SIZE];
#endif /* ACE_PI_MALLOC_PADDING_SIZE && ACE_PI_MALLOC_PADDING_SIZE == 0 */
+ /// Dump the state of the object.
void dump (void) const;
- // Dump the state of the object.
private:
ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Malloc_Header &))
};
+ /**
+ * @class ACE_Name_Node
+ *
+ * @brief This class supports "named memory regions" within <ACE_Malloc>.
+ *
+ * Internally, the named memory regions are stored as a
+ * doubly-linked list within the <Memory_Pool>. This makes
+ * it easy to iterate over the items in the list in both FIFO
+ * and LIFO order.
+ */
class ACE_Export ACE_Name_Node
{
- // = TITLE
- // This class supports "named memory regions" within <ACE_Malloc>.
- //
- // = DESCRIPTION
- // Internally, the named memory regions are stored as a
- // doubly-linked list within the <Memory_Pool>. This makes
- // it easy to iterate over the items in the list in both FIFO
- // and LIFO order.
public:
// = Initialization methods.
+ /// Constructor.
ACE_Name_Node (const char *name,
char *name_ptr,
char *pointer,
ACE_Name_Node *head);
- // Constructor.
+ /// Copy constructor.
ACE_Name_Node (const ACE_Name_Node &);
- // Copy constructor.
+ /// Constructor.
ACE_Name_Node (void);
- // Constructor.
+ /// Constructor.
~ACE_Name_Node (void);
- // Constructor.
+ /// Initialize a name node pointer.
static void init_ptr (NAME_NODE_PTR *ptr,
ACE_Name_Node *init,
void *base_addr);
- // Initialize a name node pointer.
+ /// Return a pointer to the name of this node.
const char *name (void) const;
- // Return a pointer to the name of this node.
+ /// Assign a name;
void name (const char *);
- // Assign a name;
+ /// Name of the Node.
CHAR_PTR name_;
- // Name of the Node.
+ /// Pointer to the contents.
CHAR_PTR pointer_;
- // Pointer to the contents.
+ /// Pointer to the next node in the doubly-linked list.
NAME_NODE_PTR next_;
- // Pointer to the next node in the doubly-linked list.
+ /// Pointer to the previous node in the doubly-linked list.
NAME_NODE_PTR prev_;
- // Pointer to the previous node in the doubly-linked list.
+ /// Dump the state of the object.
void dump (void) const;
- // Dump the state of the object.
private:
ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Name_Node &))
};
+ /// Print out a bunch of size info for debugging.
static void print_alignment_info (void);
- // Print out a bunch of size info for debugging.
+ /// Head of the linked list of Name Nodes.
NAME_NODE_PTR name_head_;
- // Head of the linked list of Name Nodes.
+ /// Current head of the freelist.
MALLOC_HEADER_PTR freep_;
- // Current head of the freelist.
+ /// Name of lock thats ensures mutual exclusion.
char lock_name_[MAXNAMELEN];
- // Name of lock thats ensures mutual exclusion.
#if defined (ACE_HAS_MALLOC_STATS)
// Keep statistics about ACE_Malloc state and performance.
@@ -230,15 +238,15 @@ public:
? ACE_MALLOC_ALIGN - (ACE_PI_CONTROL_BLOCK_SIZE % ACE_MALLOC_ALIGN) \
: ACE_MALLOC_ALIGN) / int (sizeof (long)))
# endif /* !ACE_PI_CONTROL_BLOCK_ALIGN_LONGS */
+ /// Force alignment.
long align_[ACE_PI_CONTROL_BLOCK_ALIGN_LONGS < 1 ? 1 : ACE_PI_CONTROL_BLOCK_ALIGN_LONGS];
- // Force alignment.
#endif /* ACE_PI_CONTROL_BLOCK_ALIGN_LONGS && ACE_PI_CONTROL_BLOCK_ALIGN_LONGS == 0 */
+ /// Dummy node used to anchor the freelist. This needs to come last...
ACE_Malloc_Header base_;
- // Dummy node used to anchor the freelist. This needs to come last...
+ /// Dump the state of the object.
void dump (void) const;
- // Dump the state of the object.
private:
ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Control_Block &))