update
This commit is contained in:
parent
6d6df7fa83
commit
392f5f5ee5
|
|
@ -16,6 +16,7 @@
|
||||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
|
||||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||||
|
<ProjectName>ECSChunkPool</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
|
|
||||||
|
|
@ -82,13 +82,13 @@ public:
|
||||||
|
|
||||||
// 迭代内存页集合
|
// 迭代内存页集合
|
||||||
for (auto page_ptr : page_list) {
|
for (auto page_ptr : page_list) {
|
||||||
auto max_element_cnt = page_ptr->maxSliceCount();
|
auto max_element_cnt = page_ptr->maxChunkCapacity();
|
||||||
auto active_cnt = page_ptr->getActiveCount();
|
auto active_cnt = page_ptr->getActiveCount();
|
||||||
// 初级校核可用数量
|
// 初级校核可用数量
|
||||||
if (active_cnt < max_element_cnt) {
|
if (active_cnt < max_element_cnt) {
|
||||||
// 逐个查找数据元素
|
// 逐个查找数据元素
|
||||||
for (auto eidx = 0; eidx < max_element_cnt; eidx++) {
|
for (auto eidx = 0; eidx < max_element_cnt; eidx++) {
|
||||||
auto slice_ptr = page_ptr->getSlicePtr(eidx);
|
auto slice_ptr = page_ptr->getChunkPtr(eidx);
|
||||||
// 访问排他
|
// 访问排他
|
||||||
slice_ptr->page_refer->lock();
|
slice_ptr->page_refer->lock();
|
||||||
// 裁决元素可用性
|
// 裁决元素可用性
|
||||||
|
|
@ -111,7 +111,7 @@ public:
|
||||||
// 生成新的内存页
|
// 生成新的内存页
|
||||||
auto new_page = new MemoryPage(MemoryElement::rawSize(T::typeSize()), type_code);
|
auto new_page = new MemoryPage(MemoryElement::rawSize(T::typeSize()), type_code);
|
||||||
_storage_pages.insert(type_code, new_page);
|
_storage_pages.insert(type_code, new_page);
|
||||||
refer_ptr = new_page->getSlicePtr(0);
|
refer_ptr = new_page->getChunkPtr(0);
|
||||||
refer_ptr->page_refer->getActiveCount(1);
|
refer_ptr->page_refer->getActiveCount(1);
|
||||||
refer_ptr->refer_count++;
|
refer_ptr->refer_count++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ MemoryPage::MemoryPage(uint16_t element_size, uint64_t typecode)
|
||||||
pcb.typecode_of_element = typecode;
|
pcb.typecode_of_element = typecode;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t MemoryPage::dataSliceSize() const
|
uint16_t MemoryPage::chunkSize() const
|
||||||
{
|
{
|
||||||
return pcb.byte_count_per_element - MemoryElement::data_buffer_offset;
|
return pcb.byte_count_per_element - MemoryElement::data_buffer_offset;
|
||||||
}
|
}
|
||||||
|
|
@ -39,9 +39,9 @@ std::pair<uint64_t, uint32_t> MemoryPage::getRecords() const {
|
||||||
return std::make_pair(pcb.curr_access_usec, pcb.acc_count_per_cycle);
|
return std::make_pair(pcb.curr_access_usec, pcb.acc_count_per_cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementControlBlock* MemoryPage::getSlicePtr(int index) {
|
ElementControlBlock* MemoryPage::getChunkPtr(int index) {
|
||||||
auto member_cnt = maxSliceCount();
|
auto member_cnt = maxChunkCapacity();
|
||||||
auto element_size = sliceRawSize();
|
auto element_size = chunkRawSize();
|
||||||
|
|
||||||
ElementControlBlock* element_ptr = nullptr;
|
ElementControlBlock* element_ptr = nullptr;
|
||||||
if (index >= 0 && index < member_cnt) {
|
if (index >= 0 && index < member_cnt) {
|
||||||
|
|
@ -79,15 +79,15 @@ uint64_t MemoryPage::elementTypeCode() const
|
||||||
return pcb.typecode_of_element;
|
return pcb.typecode_of_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t MemoryPage::sliceRawSize() const {
|
uint16_t MemoryPage::chunkRawSize() const {
|
||||||
auto data_ptr = const_cast<MemoryPage*>(this);
|
auto data_ptr = const_cast<MemoryPage*>(this);
|
||||||
std::lock_guard<std::mutex> g(data_ptr->pcb.access_protected);
|
std::lock_guard<std::mutex> g(data_ptr->pcb.access_protected);
|
||||||
return pcb.byte_count_per_element;
|
return pcb.byte_count_per_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t MemoryPage::maxSliceCount() const {
|
uint16_t MemoryPage::maxChunkCapacity() const {
|
||||||
uint16_t cnt = sizeof(data_buffer);
|
uint16_t cnt = sizeof(data_buffer);
|
||||||
return cnt / this->sliceRawSize();
|
return cnt / this->chunkRawSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// element =================================================================
|
// element =================================================================
|
||||||
|
|
@ -114,7 +114,7 @@ MemoryElement::MemoryElement(ElementControlBlock* access_bind)
|
||||||
uint16_t MemoryElement::typeSize() const
|
uint16_t MemoryElement::typeSize() const
|
||||||
{
|
{
|
||||||
auto page_ptr = data_ptr->page_refer;
|
auto page_ptr = data_ptr->page_refer;
|
||||||
return page_ptr->sliceRawSize();
|
return page_ptr->chunkRawSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryElement::accessUpdate(uint64_t time_usec)
|
void MemoryElement::accessUpdate(uint64_t time_usec)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public:
|
||||||
/// 内存存储的数据元素的尺寸
|
/// 内存存储的数据元素的尺寸
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
uint16_t dataSliceSize() const;
|
uint16_t chunkSize() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前活跃元素数量
|
/// 获取当前活跃元素数量
|
||||||
|
|
@ -95,7 +95,7 @@ public:
|
||||||
/// <param name="index">元素索引</param>
|
/// <param name="index">元素索引</param>
|
||||||
/// <param name="active_set">是否设置</param>
|
/// <param name="active_set">是否设置</param>
|
||||||
/// <returns>数据指针</returns>
|
/// <returns>数据指针</returns>
|
||||||
ElementControlBlock* getSlicePtr(int index);
|
ElementControlBlock* getChunkPtr(int index);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 元素类型码
|
/// 元素类型码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -105,12 +105,12 @@ public:
|
||||||
/// 获取单个元素尺寸
|
/// 获取单个元素尺寸
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>字节数量</returns>
|
/// <returns>字节数量</returns>
|
||||||
uint16_t sliceRawSize() const;
|
uint16_t chunkRawSize() const;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取元素数量
|
/// 获取元素数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
uint16_t maxSliceCount() const;
|
uint16_t maxChunkCapacity() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>ECSMemoryPool.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ECSChunkPool.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue