summaryrefslogtreecommitdiff
path: root/ace/Based_Pointer_Repository.h
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-07-07 04:35:44 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-07-07 04:35:44 +0000
commitc8a753e00515d0dc51e7c9c5bf1061da4d92fadb (patch)
tree11fde1a49a9c395c8c2ebf8cd19a8a17161414d3 /ace/Based_Pointer_Repository.h
parent3b6e32ebe6df9334c1c6039cec10d1efd0ba3493 (diff)
downloadATCD-c8a753e00515d0dc51e7c9c5bf1061da4d92fadb.tar.gz
.
Diffstat (limited to 'ace/Based_Pointer_Repository.h')
-rw-r--r--ace/Based_Pointer_Repository.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/ace/Based_Pointer_Repository.h b/ace/Based_Pointer_Repository.h
new file mode 100644
index 00000000000..206d845d0c8
--- /dev/null
+++ b/ace/Based_Pointer_Repository.h
@@ -0,0 +1,76 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// ace
+//
+// = FILENAME
+// Based_Pointer_Repository.h
+//
+// = AUTHOR
+// Dietrich Quehl <Dietrich.Quehl@med.siemens.de> and
+// Douglas C. Schmidt <schmidt@.cs.wustl.edu>
+//
+// ============================================================================
+
+#if !defined (ACE_BASED_POINTER_REPOSITORY_H)
+#define ACE_BASED_POINTER_REPOSITORY_H
+
+#include "ace/Singleton.h"
+#include "ace/Map_Manager.h"
+
+class ACE_Export ACE_Based_Pointer_Repository
+{
+ // = TITLE
+ // Maps pointers to the base address of the region to which each
+ // pointer belongs.
+ //
+ // = DESCRIPTION
+ // Every memory pool in ACE binds it's mapping base address and
+ // the mapped size to this repository every time it maps/remaps a
+ // new chunk of memory successfully.
+public:
+ // = Use <ACE_Null_Mutex> to allow locking while iterating.
+ typedef ACE_Map_Manager <void *, size_t *, ACE_Null_Mutex>
+ MAP_MANAGER;
+ typedef ACE_Map_Iterator < void *, size_t *, ACE_Null_Mutex>
+ MAP_ITERATOR;
+ typedef ACE_Map_Entry <void *, size_t *>
+ MAP_ENTRY;
+
+ // = Initialization and termination methods.
+ ACE_Based_Pointer_Repository (void);
+ ~ACE_Based_Pointer_Repository (void);
+
+ // = Search structure methods.
+ int find (void *addr,
+ void *&base_addr);
+ // Return the appropriate <base_addr> region that contains <addr>.
+ // Returns 1 on success and 0 if the <addr> isn't contained in any
+ // <base_addr> region.
+
+ int bind (void *addr,
+ size_t size);
+ // Bind a new entry to the repository or update the size of an
+ // existing entry. Returns 0 on success and -1 on failure.
+
+ int unbind (void *addr);
+ // Unbind from the repository the <base_addr> that <addr> is
+ // contained within.
+
+private:
+ MAP_MANAGER addr_map_;
+ // Keeps track of the mapping between addresses and their associated
+ // values.
+
+ ACE_SYNCH_MUTEX lock_;
+ // Synchronize concurrent access to the map.
+};
+
+// Provide a Singleton access point to the based pointer repository.
+typedef ACE_Singleton<ACE_Based_Pointer_Repository, ACE_SYNCH_RW_MUTEX>
+ ACE_BASED_POINTER_REPOSITORY;
+
+#endif /* ACE_BASED_POINTER_REPOSITORY_H */