summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>1997-12-01 23:09:02 +0000
committerChris Cleeland <chris.cleeland@gmail.com>1997-12-01 23:09:02 +0000
commita1d54667040b4bf3377678fa64a6610d74a82904 (patch)
treec0f77253a6c4195b9b2b802754994dc7e8eb3cee /TAO
parentde43facde4c2a5dd1dfbed42364bc8c929540d38 (diff)
downloadATCD-a1d54667040b4bf3377678fa64a6610d74a82904.tar.gz
New refcount semantics on exception/environment.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog-98c8
-rw-r--r--TAO/tao/except.cpp12
-rw-r--r--TAO/tao/except.h12
3 files changed, 21 insertions, 11 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 5f5fcf59c53..40973a42b21 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,11 @@
+Mon Dec 1 16:51:08 1997 Chris Cleeland <cleeland@cs.wustl.edu>
+
+ * tao/except.{h,i,cpp}: Changed semantics of CORBA::Exception so
+ that the mere creation of them does not take a reference.
+ Instead, the user of the exception is expected to call AddRef().
+ CORBA::Environment has been modified (and even documented!) to
+ reflect that as well.
+
Sun Nov 30 17:08:56 1997 Carlos O'Ryan <coryan@macarena.cs.wustl.edu>
* orbsvcs/lib/RtecSchedulerC.cpp:
diff --git a/TAO/tao/except.cpp b/TAO/tao/except.cpp
index 504dfd259f3..f3fe4aaae9b 100644
--- a/TAO/tao/except.cpp
+++ b/TAO/tao/except.cpp
@@ -23,22 +23,20 @@ DEFINE_GUID (IID_CORBA_SystemException,
CORBA_Exception::CORBA_Exception (CORBA::TypeCode_ptr tc)
: _type (tc),
- refcount_ (1)
+ refcount_ (0)
{
if (_type)
_type->AddRef ();
assert (_type != 0);
- assert (refcount_ > 0);
}
CORBA_Exception::CORBA_Exception (const CORBA_Exception &src)
: _type (src._type),
- refcount_ (1)
+ refcount_ (0)
{
if (_type)
_type->AddRef ();
assert (_type != 0);
- assert (refcount_ > 0);
}
// NOTE: It's this code, not anything defined in a subclass, which
@@ -62,7 +60,6 @@ CORBA_Exception::operator = (const CORBA_Exception &src)
if (_type)
_type->AddRef ();
assert (_type != 0);
- assert (refcount_ > 0);
return *this;
}
@@ -72,7 +69,6 @@ CORBA_Exception::id (void) const
{
CORBA::Environment env;
- assert (refcount_ > 0);
if (_type)
return _type->id (env);
else
@@ -82,7 +78,6 @@ CORBA_Exception::id (void) const
TAO_CONST CORBA::TypeCode_ptr
CORBA_Exception::type (void) const
{
- assert (refcount_ > 0);
return _type;
}
@@ -93,7 +88,6 @@ CORBA_Exception::AddRef (void)
{
ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, lock_, 0));
- assert (refcount_ > 0);
return ++refcount_;
}
@@ -103,7 +97,6 @@ CORBA_Exception::Release (void)
{
ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, lock_, 0));
- assert (refcount_ > 0);
refcount_--;
if (refcount_ != 0)
return refcount_;
@@ -123,7 +116,6 @@ HRESULT __stdcall
CORBA_Exception::QueryInterface (REFIID riid,
void **ppv)
{
- assert (refcount_ > 0);
*ppv = 0;
if (IID_CORBA_Exception == riid || IID_IUnknown == riid)
diff --git a/TAO/tao/except.h b/TAO/tao/except.h
index afab6df902a..b5130b7e298 100644
--- a/TAO/tao/except.h
+++ b/TAO/tao/except.h
@@ -162,9 +162,19 @@ public:
~CORBA_Environment (void) { clear (); }
CORBA::Exception_ptr exception (void) const { return _exception; }
+ // Return the exception. Caller must call AddRef() in order to keep
+ // the ptr.
void exception (CORBA::Exception *ex)
- { clear (); _exception = ex; }
+ // Set the exception to <ex>, taking a reference on it.
+ {
+ if (ex != _exception)
+ {
+ clear ();
+ _exception = ex;
+ _exception->AddRef ();
+ }
+ }
CORBA::ExceptionType exception_type (void) const;
TAO_CONST CORBA::String exception_id (void) const;