Skip to content

Commit

Permalink
[style] change UAllocator -> CAllocator
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Nov 23, 2024
1 parent d65e14c commit c5a869f
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 39 deletions.
25 changes: 13 additions & 12 deletions src/UtilsCtrl/UAllocator.h → src/CBasic/CAllocator.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/***************************
@Author: Chunel
@Contact: [email protected]
@File: UAllocator.h
@Time: 2021/10/28 9:15 下午
@File: CAllocator.h
@Time: 2024/11/23 21:54
@Desc:
***************************/

#ifndef CGRAPH_UALLOCATOR_H
#define CGRAPH_UALLOCATOR_H
#ifndef CGRAPH_CALLOCATOR_H
#define CGRAPH_CALLOCATOR_H


#include <new>
#include <mutex>
#include <memory>

#include "../CBasic/CBasicInclude.h"
#include "CObject.h"
#include "CStruct.h"
#include "CStdEx.h"

CGRAPH_NAMESPACE_BEGIN

/**
* 仅用于生成CObject类型的类
*/
class UAllocator : public CObject {
class CAllocator {
public:
/**
* 生成一个 CObject 对象
Expand Down Expand Up @@ -90,11 +90,12 @@ class UAllocator : public CObject {


#define CGRAPH_SAFE_MALLOC_COBJECT(Type) \
UAllocator::safeMallocCObject<Type>(); \
CAllocator::safeMallocCObject<Type>(); \

#define CGRAPH_MAKE_UNIQUE_COBJECT(Type) \
UAllocator::makeUniqueCObject<Type>(); \
CAllocator::makeUniqueCObject<Type>(); \

CGRAPH_NAMESPACE_END

#endif //CGRAPH_UALLOCATOR_H

#endif //CGRAPH_CALLOCATOR_H
1 change: 1 addition & 0 deletions src/CBasic/CBasicInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
#include "CStdEx.h"
#include "CDescInfo.h"
#include "CStruct.h"
#include "CAllocator.h"

#endif //CGRAPH_CBASICINCLUDE_H
5 changes: 2 additions & 3 deletions src/CBasic/CStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ CGRAPH_NAMESPACE_BEGIN
* 所有框架内部结构体定义的基类
* 仅针对类似 pod 数据类型的定义
*/
class CStruct {
public:
~CStruct() = default;
struct CStruct {
virtual ~CStruct() = default;
};

CGRAPH_NAMESPACE_END
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphAspect/GAspectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GAspectManager : public GAspectObject,
GAspectPtrArr aspect_arr_; // 存储aspect的容器

friend class GElement;
friend class UAllocator;
friend class CAllocator;
};

using GAspectManagerPtr = GAspectManager *;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphDaemon/GDaemonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GDaemonManager : public GDaemonObject,
CSize getSize() const final;

friend class GPipeline;
friend class UAllocator;
friend class CAllocator;
CGRAPH_NO_ALLOWED_COPY(GDaemonManager)

private:
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElement.inl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GElementPtr GElement::addGAspect(Args... args) {
aspect_manager_ = CGRAPH_SAFE_MALLOC_COBJECT(GAspectManager)
}

auto aspect = UAllocator::safeMallocTemplateCObject<TAspect>(std::forward<Args>(args)...);
auto aspect = CAllocator::safeMallocTemplateCObject<TAspect>(std::forward<Args>(args)...);
aspect->setBelong(this);
aspect_manager_->add(aspect);
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElementManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class GElementManager : public GElementObject,
friend class GRegion;
friend class GMutable;
friend class GPerf;
friend class UAllocator;
friend class CAllocator;
};

using GElementManagerPtr = GElementManager *;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GCluster : public GGroup {

friend class GPipeline;
friend class GDynamicEngine;
friend class UAllocator;
friend class CAllocator;
};

CGRAPH_NAMESPACE_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GMultiCondition : public GCondition {
CBool isSeparate(GElementCPtr a, GElementCPtr b) const final;

friend class GPipeline;
friend class UAllocator;
friend class CAllocator;
};

CGRAPH_NAMESPACE_END
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GMutable : public GGroup {
GElementManagerPtr manager_ = nullptr;

friend class GPipeline;
friend class UAllocator;
friend class CAllocator;
};

using GMutablePtr = GMutable *;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GRegion : public GGroup {
CGRAPH_NO_ALLOWED_COPY(GRegion)

friend class GPipeline;
friend class UAllocator;
friend class CAllocator;
friend class GTrimOptimizer;
};

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GSome/GSome.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class GSome : public GGroup {

friend class GPipeline;
friend class GDynamicEngine;
friend class UAllocator;
friend class CAllocator;
};

CGRAPH_NAMESPACE_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GDynamicEngine : public GEngine {
std::condition_variable cv_;
std::mutex status_lock_;

friend class UAllocator;
friend class CAllocator;
};

CGRAPH_NAMESPACE_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GStaticEngine : public GEngine {
private:
GElementPtrMat2D element_mat_ {}; // 解图后的elements信息

friend class UAllocator;
friend class CAllocator;
friend class GElementManager;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GTopoEngine : public GEngine {
private:
GElementPtrArr topo_elements_ {}; // 拓扑排序后的

friend class UAllocator;
friend class CAllocator;
friend class GElementManager;
};

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphEvent/GEventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class GEventManager : public GEventObject,
private:
std::unordered_map<std::string, GEventPtr> events_map_; // event 管理类

friend class UAllocator;
friend class CAllocator;
friend class GPipeline;
};

Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphMessage/GMessageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GMessageManager : public GMessageObject,
? CStatus() : CStatus("create topic [" + topic + "] duplicate");
} else {
// 创建一个 topic信息
auto message = UAllocator::safeMallocTemplateCObject<GMessage<TImpl>>(size);
auto message = CAllocator::safeMallocTemplateCObject<GMessage<TImpl>>(size);
send_recv_message_map_.insert(std::pair<const std::string&, GMessagePtr<T> >(innerTopic, GMessagePtr<T>(message)));
}

Expand Down Expand Up @@ -196,7 +196,7 @@ class GMessageManager : public GMessageObject,
auto innerTopic = internal::PUB_SUB_PREFIX + topic;

CGRAPH_LOCK_GUARD lk(pub_sub_mutex_);
auto message = UAllocator::safeMallocTemplateCObject<GMessage<TImpl>>(size);
auto message = CAllocator::safeMallocTemplateCObject<GMessage<TImpl>>(size);
CIndex connId = (++cur_conn_id_);
auto result = pub_sub_message_map_.find(innerTopic);
if (result != pub_sub_message_map_.end()) {
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphParam/GParamManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GParamManager : public GParamObject,
std::mutex mutex_; // 创建param的时候上锁

friend class GPipeline;
friend class UAllocator;
friend class CAllocator;
};

using GParamManagerPtr = GParamManager *;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphPipeline/GPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class GPipeline : public GPipelineObject,
GElementRepository repository_; // 记录创建的所有element的仓库

friend class GPipelineFactory;
friend class UAllocator;
friend class CAllocator;
friend class GPerf;
};

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphPipeline/GPipeline.inl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ GPipelinePtr GPipeline::addGDaemon(CMSec ms, Args&&... args) {
CGRAPH_ASSERT_INIT_THROW_ERROR(false)
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(param_manager_, daemon_manager_)

auto daemon = UAllocator::safeMallocTemplateCObject<TDaemon>(std::forward<Args &&>(args)...);
auto daemon = CAllocator::safeMallocTemplateCObject<TDaemon>(std::forward<Args &&>(args)...);
daemon->setInterval(ms);
daemon->setGParamManager(this->param_manager_);
daemon->setGEventManager(this->event_manager_);
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphPipeline/_GPerf/GPerf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CStatus GPerf::inject(GPipelinePtr pipeline) {
* 给其中的每个element,都添加这个切面信息
* 这里是不需要考虑 delete perf_info_的,因为在 element结束的时候,会自动释放
*/
cur->perf_info_ = UAllocator::safeMallocCStruct<GPerfInfo>();
cur->perf_info_ = CAllocator::safeMallocCStruct<GPerfInfo>();
cur->addGAspect<GPerfAspect<CFMSec, GPerfInfoPtr>>(now, cur->perf_info_);
}
CGRAPH_FUNCTION_END
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphPipeline/_GPerf/GPerfAspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GPerfAspect : public GTemplateAspect<Args ...> {
CFMSec cur_start_ts_ = 0.0; // 当前element开始运行的时间
GPerfInfoPtr perf_info_ = nullptr; // 具体赋值的对象

friend class UAllocator;
friend class CAllocator;
};

CGRAPH_NAMESPACE_END
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CStatus GSchedule::init() {
* 如果是 shared 的数据,则不做任何操作
*/
CGRAPH_DELETE_PTR(unique_tp_)
unique_tp_ = UAllocator::safeMallocTemplateCObject<UThreadPool>(true, config_);
unique_tp_ = CAllocator::safeMallocTemplateCObject<UThreadPool>(true, config_);
} else if (internal::GScheduleType::SHARED == type_) {
CGRAPH_ASSERT_NOT_NULL(shared_tp_)
// 首先,要确定外部传入的线程池,已经初始化过了
Expand Down
2 changes: 1 addition & 1 deletion src/UtilsCtrl/ThreadPool/Thread/UThreadPrimary.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class UThreadPrimary : public UThreadBase {
std::vector<CInt> steal_targets_; // 被偷的目标信息

friend class UThreadPool;
friend class UAllocator;
friend class CAllocator;
};

using UThreadPrimaryPtr = UThreadPrimary *;
Expand Down
1 change: 0 additions & 1 deletion src/UtilsCtrl/UtilsDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#endif

#include "../CBasic/CBasicInclude.h"
#include "UAllocator.h"
#include "UtilsFunction.h"

CGRAPH_NAMESPACE_BEGIN
Expand Down
1 change: 0 additions & 1 deletion src/UtilsCtrl/UtilsInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define CGRAPH_UTILSINCLUDE_H

#include "UtilsDefine.h"
#include "UAllocator.h"
#include "ThreadPool/UThreadPoolInclude.h"
#include "Singleton/USingleton.h"
#include "Lru/ULru.h"
Expand Down

0 comments on commit c5a869f

Please sign in to comment.