summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp
blob: b0d869ce2e4b62f03976db30b3239a90bbe3a628 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// $Id$

#include "Refcountable.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"
#include "ace/Guard_T.h"

ACE_RCSID(Notify, TAO_Notify_Refcountable, "$Id$")

TAO_Notify_Refcountable::TAO_Notify_Refcountable (void)
  :refcount_ (1)
{
}

TAO_Notify_Refcountable::~TAO_Notify_Refcountable ()
{
}

CORBA::ULong
TAO_Notify_Refcountable::_incr_refcnt (void)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);

  if (TAO_debug_level > 1 )
    ACE_DEBUG ((LM_DEBUG,"object:%x  incr refcount = %d\n", this, refcount_+1 ));


  return this->refcount_++;
}

CORBA::ULong
TAO_Notify_Refcountable::_decr_refcnt (void)
{
  {
    ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);

    if (TAO_debug_level > 1 )
      ACE_DEBUG ((LM_DEBUG,"object:%x  decr refcount = %d\n", this, refcount_-1 ));

    this->refcount_--;
    if (this->refcount_ != 0)
      return this->refcount_;
  }

  this->release ();

  return 0;
}