优化frame性能及整理代码

This commit is contained in:
xia-chu
2021-02-05 11:51:16 +08:00
parent c5cfbce241
commit 62ba87dd0f
33 changed files with 847 additions and 855 deletions

View File

@@ -130,7 +130,10 @@ private:
class FrameImp : public Frame {
public:
typedef std::shared_ptr<FrameImp> Ptr;
using Ptr = std::shared_ptr<FrameImp>;
template<typename C=FrameImp>
static std::shared_ptr<C> create();
char *data() const override{
return (char *)_buffer.data();
@@ -172,6 +175,13 @@ public:
BufferLikeString _buffer;
//对象个数统计
ObjectStatistic<FrameImp> _statistic;
protected:
friend class ResourcePool_l<FrameImp>;
FrameImp() = default;
template<typename C>
static std::shared_ptr<C> create_l();
};
/**
@@ -195,26 +205,6 @@ private:
Frame::Ptr _parent_frame;
};
/**
* 循环池辅助类
*/
template <typename T>
class ResourcePoolHelper{
public:
ResourcePoolHelper(int size = 0){
if (size > 0) {
_pool.setSize(size);
}
}
virtual ~ResourcePoolHelper(){}
std::shared_ptr<T> obtainObj(){
return _pool.obtain();
}
private:
ResourcePool<T> _pool;
};
/**
* 写帧接口的抽象接口类
*/