summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-24 14:36:08 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-24 14:36:08 +0000
commitb6245769053a32e00ac22fd4c9330c0d8904707d (patch)
tree20ef3d849cf87bfade20625b4485d10b880eafc5 /ace
parente181d4dbafa7d900751f48df6848017099696a78 (diff)
downloadATCD-b6245769053a32e00ac22fd4c9330c0d8904707d.tar.gz
removed ACE_Managed_Object get_object () interface
Diffstat (limited to 'ace')
-rw-r--r--ace/Managed_Object.cpp56
-rw-r--r--ace/Managed_Object.h31
-rw-r--r--ace/Object_Manager.cpp10
-rw-r--r--ace/Object_Manager.h6
4 files changed, 13 insertions, 90 deletions
diff --git a/ace/Managed_Object.cpp b/ace/Managed_Object.cpp
index 5ca197c1383..9c915a4366e 100644
--- a/ace/Managed_Object.cpp
+++ b/ace/Managed_Object.cpp
@@ -5,66 +5,10 @@
#if !defined (ACE_MANAGED_OBJECT_CPP)
#define ACE_MANAGED_OBJECT_CPP
-#include "ace/Object_Manager.h"
#include "ace/Managed_Object.h"
-#if !defined (ACE_TEMPLATES_REQUIRE_SOURCE)
-# include "ace/Synch.h"
-#endif /* !ACE_TEMPLATES_REQUIRE_SOURCE */
#if !defined (__ACE_INLINE__)
#include "ace/Managed_Object.i"
#endif /* __ACE_INLINE__ */
-template <class TYPE>
-int
-ACE_Managed_Object<TYPE>::get_object (int &id, TYPE *&object)
-{
- // Use the ACE_Object_Manager instance's lock.
- ACE_MT (ACE_Thread_Mutex &lock = *ACE_Object_Manager::instance ()->lock_);
- ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock, -1));
-
- if (id == 0)
- {
- // User is requesting a new object.
- if (ACE_Object_Manager::next_managed_object < ACE_MAX_MANAGED_OBJECTS)
- {
- // Allocate a new object, store it in the table, and return it.
- ACE_NEW_RETURN (object, TYPE, -1);
- if (object == 0)
- {
- errno = ENOMEM;
- return -1;
- }
- else
- {
- id = ACE_Object_Manager::next_managed_object + 1;
- ACE_Object_Manager::managed_object[
- ACE_Object_Manager::next_managed_object++] = object;
- return 0;
- }
- }
- else
- {
- // No more managed_object table slots.
- object = 0;
- errno = ENOSPC;
- return -1;
- }
- }
- else if (id < 0 || (u_int) id > ACE_Object_Manager::next_managed_object)
- {
- // Unknown, non-zero, or negative id.
- object = 0;
- errno = ENOENT;
- return -1;
- }
- else
- {
- // id is known, so return the object. Cast its type based
- // on the type of the function template parameter.
- object = (TYPE *) ACE_Object_Manager::managed_object[id - 1];
- return 0;
- }
-}
-
#endif /* ACE_MANAGED_OBJECT_CPP */
diff --git a/ace/Managed_Object.h b/ace/Managed_Object.h
index 56b34c838f7..0eb87390f0c 100644
--- a/ace/Managed_Object.h
+++ b/ace/Managed_Object.h
@@ -18,6 +18,7 @@
#define ACE_MANAGED_OBJECT_H
#include "ace/OS.h"
+#include "ace/Object_Manager.h"
template <class TYPE>
class ACE_Cleanup_Adapter : public ACE_Cleanup
@@ -26,9 +27,12 @@ class ACE_Cleanup_Adapter : public ACE_Cleanup
// managed by the ACE_Object_Manager.
//
// = DESCRIPTION
- // This template class wraps adapts an object of any type to be
- // an ACE_Cleanup object. The object can then be destroyed
- // type-safely by the ACE_Object_Manager.
+ // This template class adapts an object of any type to be an
+ // ACE_Cleanup object. The object can then be destroyed
+ // type-safely by the ACE_Object_Manager. This class is
+ // typically used to replace a cast; but, it's a bit cleaner and
+ // allows insertion of, say, run-time type identification
+ // internally if desired.
{
public:
ACE_Cleanup_Adapter (void);
@@ -61,18 +65,6 @@ class ACE_Managed_Object
// be allocated when first needed. And they are destroyed in
// the reverse order of construction.
//
- // To use the get_object () interface, the caller must provide
- // an identifier and an object pointer. The identifer (usually)
- // has a value of 0 the first time get_object () is called, in
- // which case a new instance of the object is allocated on the
- // heap. (See the description of get_object () for return
- // values.)
- //
- // Subsequent calls to get_object (), with that identifier, will
- // return the pointer to the identified object. The caller is
- // responsible for ensuring type safety by not casting the pointer
- // that it holds in calls to get_object ().
- //
// get_preallocated_object () accesses a "preallocated" object,
// i.e., one that is identified by a value in the
// ACE_Object_Manager:: Preallocated_Object enum. These
@@ -97,15 +89,6 @@ class ACE_Managed_Object
// the ACE library.
{
public:
- static int get_object (int &id, TYPE *&object);
- // Get the object identified by "id". If "id" is 0, allocates a new
- // instance, and sets "id" to the new identifier for that instance.
- // Returns 0 on success. On failure, returns -1 and sets errno to:
- // ENOENT if the id is non-zero and unknown,
- // ENOMEM if insufficient virtual memory to allocate a new instance, or
- // ENOSPC if no more table slots are available: see the
- // ACE_MAX_MANAGED_OBJECTS config variable.
-
static
TYPE *get_preallocated_object (ACE_Object_Manager::Preallocated_Object id);
// Get the preallocated object identified by "id". Returns a
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp
index 6bbd4bd4edb..30c0ac89d27 100644
--- a/ace/Object_Manager.cpp
+++ b/ace/Object_Manager.cpp
@@ -257,13 +257,13 @@ ACE_Object_Manager::at_exit_i (void *object,
class ACE_Export ACE_Object_Manager_Destroyer
// = TITLE
// Ensure that the <ACE_Object_Manager> gets initialized before any
- // application threads have been spawned.
+ // application threads have been spawned, and destroyed at program
+ // termination.
//
// = DESCRIPTION
- // The <ACE_Object_Manager_Destroyer> class is placed in this
- // file, rather than Object_Manager.cpp, to be sure that the
- // static Object_Manager gets linked into applications that
- // statically link libACE.a.
+ // Without ACE_HAS_NONSTATIC_OBJECT_MANAGER, a static instance of this
+ // class is created. Therefore, it gets created before main ()
+ // is called. And it gets destroyed after main () returns.
{
public:
ACE_Object_Manager_Destroyer (void);
diff --git a/ace/Object_Manager.h b/ace/Object_Manager.h
index 80f1381f42c..56e5804a05a 100644
--- a/ace/Object_Manager.h
+++ b/ace/Object_Manager.h
@@ -93,14 +93,10 @@ class ACE_Export ACE_Object_Manager
// can be used to register an ACE_Cleanup object
// for any cleanup activity at program termination.
//
- // 3) ACE_Managed_Object::get_object (int &id, TYPE *&object);
- // can be used to dynamically allocate an object of any TYPE.
- // The object is deleted at program termination.
- //
// The final mechanism is not general purpose, but can only
// be used to allocate objects and arrays at program startup:
//
- // 4) ACE_Managed_Object::get_preallocated_object
+ // 3) ACE_Managed_Object::get_preallocated_object
// (ACE_Object_Manager::Preallocated_Object id);
// and
// ACE_Managed_Object::get_preallocated_array