Compare commits
No commits in common. "618e2b7a2a86f4163a886ec9eada2eb5232954d8" and "4fdacb92940bef828e9ede18057feedd86d6bf44" have entirely different histories.
618e2b7a2a
...
4fdacb9294
@ -10,22 +10,6 @@
|
|||||||
|
|
||||||
ETK_DECLARE_TYPE(ememory::RefCounter);
|
ETK_DECLARE_TYPE(ememory::RefCounter);
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
static int32_t& getLocalDebugCounter() {
|
|
||||||
static int32_t g_uid = 0;
|
|
||||||
return g_uid;
|
|
||||||
}
|
|
||||||
void ememory::resetDebugRefCounter() {
|
|
||||||
getLocalDebugCounter() = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ememory::RefCounter::RefCounter() {
|
|
||||||
#ifdef DEBUG
|
|
||||||
m_uid = getLocalDebugCounter()++;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
ememory::RefCounter::~RefCounter() {
|
ememory::RefCounter::~RefCounter() {
|
||||||
if (m_refCount != 0) {
|
if (m_refCount != 0) {
|
||||||
EMEMORY_ERROR("delete a RefCounted element that is keep by somewhere !! " << m_refCount);
|
EMEMORY_ERROR("delete a RefCounted element that is keep by somewhere !! " << m_refCount);
|
||||||
@ -46,23 +30,11 @@ void ememory::RefCounter::refRelease() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (refCount < 0) {
|
if (refCount < 0) {
|
||||||
#ifdef DEBUG
|
EMEMORY_ERROR("request release a refcounted One more time than needed !! " << m_refCount);
|
||||||
EMEMORY_ERROR("request release a refcounted One more time than needed !! " << m_refCount << " uid=" << m_uid);
|
|
||||||
#else
|
|
||||||
EMEMORY_ERROR("request release a refcounted One more time than needed !! " << m_refCount);
|
|
||||||
#endif
|
|
||||||
m_refCount = 0;
|
m_refCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ememory::RefCounter::getRefCount() const {
|
int ememory::RefCounter::getRefCount() const {
|
||||||
return m_refCount;
|
return m_refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t ememory::RefCounter::getRawPointer() const {
|
|
||||||
#ifdef DEBUG
|
|
||||||
return m_uid;
|
|
||||||
#endif
|
|
||||||
return uint64_t(this);
|
|
||||||
}
|
|
@ -14,19 +14,11 @@ namespace ememory {
|
|||||||
* @brief Use the element as a refcounted element
|
* @brief Use the element as a refcounted element
|
||||||
*/
|
*/
|
||||||
class RefCounter {
|
class RefCounter {
|
||||||
#ifndef ETK_MEMORY_CHECKER
|
protected:
|
||||||
protected:
|
|
||||||
#else
|
|
||||||
public:
|
|
||||||
#endif
|
|
||||||
RefCounter();
|
|
||||||
// Virtualize destructor in private to prevent user ot remove it without permition
|
// Virtualize destructor in private to prevent user ot remove it without permition
|
||||||
virtual ~RefCounter();
|
virtual ~RefCounter();
|
||||||
private:
|
private:
|
||||||
int32_t m_refCount = 1;
|
int32_t m_refCount = 1;
|
||||||
#ifdef DEBUG
|
|
||||||
int32_t m_uid;
|
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Keep a copy of this reference-counted element.
|
* @brief Keep a copy of this reference-counted element.
|
||||||
@ -50,15 +42,7 @@ namespace ememory {
|
|||||||
* @return Request const SharedPtr
|
* @return Request const SharedPtr
|
||||||
*/
|
*/
|
||||||
//const ememory::RefPtr<EMEMORY_TYPE> refFromThis() const;
|
//const ememory::RefPtr<EMEMORY_TYPE> refFromThis() const;
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* @brief get the RAW pointer value of this element (for debug only)
|
|
||||||
*/
|
|
||||||
uint64_t getRawPointer() const;
|
|
||||||
};
|
};
|
||||||
#ifdef DEBUG
|
|
||||||
void resetDebugRefCounter();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <ememory/details/EnableSharedFromThis.hxx>
|
#include <ememory/details/EnableSharedFromThis.hxx>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import realog.debug as debug
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import realog.debug as debug
|
import lutin.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user