Skip to content

Commit

Permalink
TypedObjPool管理使用LLBC_CString, 以规避不同module rtti指针不同引发的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lailongwei committed Sep 6, 2024
1 parent 380ec97 commit 6115e68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions llbc/include/llbc/core/objpool/ObjPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ class LLBC_EXPORT LLBC_ObjPool final
// The wrapped TypedObjPool structure encapsulation.
struct _WrappedTypedObjPool
{
const char *rttiName;
LLBC_CString rttiName;
void (*ReleaseObj)(void *, void *);
void (*Destruct)(void *);
void (*Collect)(void *, bool);
Expand Down Expand Up @@ -846,7 +846,7 @@ class LLBC_EXPORT LLBC_ObjPool final
mutable LLBC_SpinLockHandle _lock;

// Typed object pools.
std::map<const char *, _WrappedTypedObjPool *> _typedObjPools;
std::map<LLBC_CString, _WrappedTypedObjPool *> _typedObjPools;

// Ordered delete nodes & node tree.
std::map<LLBC_CString, _OrderedDeleteNode *> *_orderedDeleteNodes;
Expand Down
9 changes: 2 additions & 7 deletions llbc/include/llbc/core/objpool/ObjPoolInl.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ template <typename Obj>
LLBC_FORCE_INLINE LLBC_TypedObjPool<Obj> *LLBC_ObjPool::GetTypedObjPool()
{
typedef LLBC_TypedObjPool<Obj> _TypedObjPool;
static const char *rttiName = typeid(Obj).name();
static const LLBC_CString rttiName(typeid(Obj).name());

// Lock.
__LLBC_INL_LockObjPool();
Expand Down Expand Up @@ -966,12 +966,7 @@ inline void LLBC_ObjPool::OperateOneOrderedDeleteNode(_OrderedDeleteNode *ordere
bool isCollect,
bool deepCollect)
{
const auto it = std::find_if(_typedObjPools.begin(),
_typedObjPools.end(),
[orderedDelNode](const std::pair<const char *, _WrappedTypedObjPool *> &item) {
return orderedDelNode->GetName() == item.first;
});

const auto it = _typedObjPools.find(orderedDelNode->GetName());
if (it != _typedObjPools.end())
{
auto wrappedTypedObjPool = it->second;
Expand Down

0 comments on commit 6115e68

Please sign in to comment.