Version: 9.16.0
RefCounter.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "RefCounter.hxx"
21
22#include "Mutex.hxx"
23
24//#define REFCNT
25
26#include <iostream>
27#include <sstream>
28
29//#define _DEVDEBUG_
30#include "YacsTrace.hxx"
31
32using namespace YACS::ENGINE;
33
34unsigned int RefCounter::_totalCnt=0;
35
36static YACS::BASES::Mutex _globalMutexForTS;
37
38void RefCounter::incrRef() const
39{
40 _globalMutexForTS.lock();
41#ifdef REFCNT
43#endif
44 _cnt++;
45 _globalMutexForTS.unLock();
46}
47
49{
50 _globalMutexForTS.lock();
51#ifdef REFCNT
53#endif
54 bool ret=(--_cnt==0);
55 _globalMutexForTS.unLock();
56 if(ret)
57 delete this;
58 return ret;
59}
60
62{
63#ifdef REFCNT
65#endif
66}
67
69{
70}
71
73{
74#ifdef REFCNT
75 if(_cnt > 0)
76 {
77 DEBTRACE("Ref count > 0: " << this << " " << _cnt);
79 }
80#endif
81}
static YACS::BASES::Mutex _globalMutexForTS
Definition: RefCounter.cxx:36
void AttachDebugger()
Definition: YacsTrace.cxx:52
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
static unsigned int _totalCnt
Definition: RefCounter.hxx:35