Skip to content

Commit

Permalink
Fea,添加BuildYY_ThunksLibraries支持
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Jun 2, 2024
1 parent 1a71e74 commit 5a1a603
Show file tree
Hide file tree
Showing 7 changed files with 1,273 additions and 96 deletions.
28 changes: 2 additions & 26 deletions LibMaker.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibMaker", "LibMaker\LibMaker.vcxproj", "{30715830-71CE-4CE8-AB47-63AF621B4B07}"
EndProject
Expand All @@ -11,14 +11,6 @@ Global
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
v140|x64 = v140|x64
v140|x86 = v140|x86
v140xp|x64 = v140xp|x64
v140xp|x86 = v140xp|x86
v141|x64 = v141|x64
v141|x86 = v141|x86
v141xp|x64 = v141xp|x64
v141xp|x86 = v141xp|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30715830-71CE-4CE8-AB47-63AF621B4B07}.Debug|x64.ActiveCfg = Debug|x64
Expand All @@ -29,22 +21,6 @@ Global
{30715830-71CE-4CE8-AB47-63AF621B4B07}.Release|x64.Build.0 = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.Release|x86.ActiveCfg = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.Release|x86.Build.0 = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140|x64.ActiveCfg = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140|x64.Build.0 = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140|x86.ActiveCfg = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140|x86.Build.0 = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140xp|x64.ActiveCfg = Debug|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140xp|x64.Build.0 = Debug|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140xp|x86.ActiveCfg = Debug|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v140xp|x86.Build.0 = Debug|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141|x64.ActiveCfg = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141|x64.Build.0 = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141|x86.ActiveCfg = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141|x86.Build.0 = Release|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141xp|x64.ActiveCfg = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141xp|x64.Build.0 = Release|x64
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141xp|x86.ActiveCfg = Debug|Win32
{30715830-71CE-4CE8-AB47-63AF621B4B07}.v141xp|x86.Build.0 = Debug|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
74 changes: 74 additions & 0 deletions LibMaker/InterlockedQueue.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#pragma once

template<class Entry, size_t kMaxBlockSize>
class InterlockedQueue
{
private:
struct Block
{
size_t uLastReadIndex = 0;
size_t uLastWriteIndex = 0;
Block* pNextBlock = nullptr;
Entry* arrLoopBuffer[kMaxBlockSize];

bool IsEmpty()
{
return uLastReadIndex == uLastWriteIndex;
}

bool IsFull()
{
return uLastReadIndex + kMaxBlockSize == uLastWriteIndex;
}
};

Block* pFirstReadBlock = nullptr;
Block* pLastWriteBlock = nullptr;

public:
Entry* Pop() noexcept
{
if (!pFirstReadBlock)
return nullptr;

for (;;)
{
// 当前块任然有元素?
if (!pFirstReadBlock->IsEmpty())
{
auto _pTmp = pFirstReadBlock->arrLoopBuffer[pFirstReadBlock->uLastReadIndex % kMaxBlockSize];
pFirstReadBlock->uLastReadIndex += 1;
return _pTmp;
}

// 尝试流转到下一块
if (!pFirstReadBlock->pNextBlock)
return nullptr;

auto _pPendingDelete = pFirstReadBlock;
pFirstReadBlock = pFirstReadBlock->pNextBlock;
delete _pPendingDelete;
}

return nullptr;
}

void Push(_In_ Entry* _pEntry)
{
if (!pLastWriteBlock)
{
pFirstReadBlock = pLastWriteBlock = new Block();
}

// 如果满了就尝试链接到下一块
if (pLastWriteBlock->IsFull())
{
auto _pNextBlock = new Block();
pLastWriteBlock->pNextBlock = _pNextBlock;
pLastWriteBlock = _pNextBlock;
}

pLastWriteBlock->arrLoopBuffer[pLastWriteBlock->uLastWriteIndex % kMaxBlockSize] = _pEntry;
pLastWriteBlock->uLastWriteIndex += 1;
}
};
Loading

0 comments on commit 5a1a603

Please sign in to comment.