Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LimaGroup
Lima
Commits
431e6b59
Commit
431e6b59
authored
Sep 25, 2020
by
Samuel Debionne
Browse files
Do not destroy default Allocator until it's empty
parent
4c951208
Changes
4
Hide whitespace changes
Inline
Side-by-side
common/include/lima/MemUtils.h
View file @
431e6b59
...
...
@@ -59,13 +59,6 @@ struct LIMACORE_API Allocator
"Moved-from Allocator is not empty"
);
}
~
Allocator
()
{
if
(
m_ref_count
!=
0
)
std
::
cerr
<<
"Error: destroying non-empty Allocator"
<<
std
::
endl
;
}
// Allocate a buffer of a given size and eventually return
// the associated allocator data and potentially modified size
virtual
DataPtr
alloc
(
void
*
&
ptr
,
size_t
&
size
,
size_t
alignment
=
16
);
...
...
@@ -107,11 +100,18 @@ struct LIMACORE_API Allocator
protected:
friend
class
Ref
;
virtual
~
Allocator
()
{
if
(
m_ref_count
!=
0
)
std
::
cerr
<<
"Error: destroying non-empty Allocator"
<<
std
::
endl
;
}
// The real resource management counter, triggered by Ref
Allocator
*
get
()
{
return
++
m_ref_count
,
this
;
}
void
put
()
{
--
m_ref_count
;
}
{
if
(
--
m_ref_count
==
0
)
delete
this
;
}
// Keep track of allocated buffers pointing to this Allocator:
// if greather than 0 this object cannot be moved
...
...
common/src/MemUtils.cpp
View file @
431e6b59
...
...
@@ -108,8 +108,8 @@ void lima::ClearBuffer(void *ptr, int nb_concat_frames,
Allocator
*
Allocator
::
defaultAllocator
()
{
static
Allocator
allocator
;
return
&
allocator
;
static
Allocator
::
Ref
allocator
=
new
Allocator
()
;
return
allocator
;
}
Allocator
::
DataPtr
Allocator
::
alloc
(
void
*
&
ptr
,
size_t
&
size
,
size_t
alignment
)
...
...
hardware/include/lima/HwBufferMgr.h
View file @
431e6b59
...
...
@@ -97,7 +97,7 @@ class LIMACORE_API SoftBufferAllocMgr : public BufferAllocMgr
typedef
BufferList
::
const_reverse_iterator
BufferListCRIt
;
FrameDim
m_frame_dim
;
Allocator
*
m_allocator
;
Allocator
::
Ref
m_allocator
;
BufferList
m_buffer_list
;
};
...
...
@@ -116,7 +116,7 @@ class LIMACORE_API NumaSoftBufferAllocMgr : public SoftBufferAllocMgr
void
setCPUAffinityMask
(
unsigned
long
mask
);
protected:
AutoPtr
<
NumaAllocator
>
m_numa_allocator
;
NumaAllocator
*
m_numa_allocator
;
};
#endif //LIMA_USE_NUMA
...
...
hardware/src/HwBufferMgr.cpp
View file @
431e6b59
...
...
@@ -60,9 +60,9 @@ void BufferAllocMgr::clearAllBuffers()
*******************************************************************/
SoftBufferAllocMgr
::
SoftBufferAllocMgr
()
:
m_allocator
(
Allocator
::
defaultAllocator
())
{
DEB_CONSTRUCTOR
();
setAllocator
(
Allocator
::
defaultAllocator
());
}
SoftBufferAllocMgr
::~
SoftBufferAllocMgr
()
...
...
@@ -169,6 +169,7 @@ void *SoftBufferAllocMgr::getBufferPtr(int buffer_nb)
#ifdef LIMA_USE_NUMA
NumaSoftBufferAllocMgr
::
NumaSoftBufferAllocMgr
()
:
m_numa_allocator
(
NULL
)
{
DEB_CONSTRUCTOR
();
setCPUAffinityMask
(
0
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment