Skip to content

Commit

Permalink
fix printf("%d", atomic_int) compiling error in vs2017
Browse files Browse the repository at this point in the history
fix back thread hanging the main thread bug(comment back thread, use web to execute commands)
  • Loading branch information
nickyang4github committed Mar 9, 2018
1 parent 0ac07eb commit 101e79c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Frame/SDK/Core/Base/AFMemAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void AFMemAlloc::CheckLeak()
}
else
{
printf("Find leak, %d bytes!\n", g_totalAlloc);
printf("Find leak, %d bytes!\n", g_totalAlloc.load());
for (auto& iter : g_memMap)
{
AllocItem& record = iter.second;
Expand Down
36 changes: 17 additions & 19 deletions Frame/SDK/PluginLoader/AFPluginLoader.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This source file is part of ArkGameFrame
* For the latest info, see https://github.com/ArkGame
*
Expand Down Expand Up @@ -38,25 +38,25 @@ std::string strPluginName;

#include <Dbghelp.h>
#pragma comment( lib, "DbgHelp" )
// 创建Dump文件
// 创建Dump文件
void CreateDumpFile(const std::string& strDumpFilePathName, EXCEPTION_POINTERS* pException)
{
// 创建Dump文件
// 创建Dump文件
HANDLE hDumpFile = CreateFile(strDumpFilePathName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

// Dump信息
// Dump信息
MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
dumpInfo.ExceptionPointers = pException;
dumpInfo.ThreadId = GetCurrentThreadId();
dumpInfo.ClientPointers = TRUE;

// 写入Dump文件内容
// 写入Dump文件内容
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL);

CloseHandle(hDumpFile);
}

// 处理Unhandled Exception的回调函数
// 处理Unhandled Exception的回调函数
long ApplicationCrashHandler(EXCEPTION_POINTERS* pException)
{
time_t t = time(0);
Expand Down Expand Up @@ -101,9 +101,9 @@ void ThreadFunc()

void CreateBackThread()
{
auto f = std::async(std::launch::async, ThreadFunc);
//gThread = std::thread(std::bind(&ThreadFunc));
//std::cout << "CreateBackThread, thread ID = " << gThread.get_id() << std::endl;
gThread = std::thread(std::bind(&ThreadFunc));
std::cout << "CreateBackThread, thread ID = " << gThread.get_id() << std::endl;
gThread.join();
}

void InitDaemon()
Expand All @@ -122,19 +122,17 @@ void InitDaemon()
#endif
}

void PrintfLogo()
void PrintLogo()
{
#if ARK_PLATFORM == PLATFORM_WIN
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
#endif

std::cout << "********************************************" << std::endl;
std::cout << std::endl;
std::cout << " \t ARK" << std::endl;
std::cout << " COPYRIGHT (C) 2013-2018 ARK-GAME" << std::endl;
std::cout << " All RIGHTS RESERVED." << std::endl;
std::cout << " HTTPS://ARKGAME.NET" << std::endl;
std::cout << std::endl;
std::cout << "ARK" << std::endl;
std::cout << "COPYRIGHT © 2013-2018 ARK-GAME" << std::endl;
std::cout << "All RIGHTS RESERVED." << std::endl;
std::cout << "HTTPS://ARKGAME.NET" << std::endl;
std::cout << "********************************************" << std::endl;

#if ARK_PLATFORM == PLATFORM_WIN
Expand All @@ -144,7 +142,7 @@ void PrintfLogo()

int main(int argc, char* argv[])
{
PrintfLogo();
PrintLogo();

for(int i = 0; i < argc; i++)
{
Expand Down Expand Up @@ -188,9 +186,9 @@ int main(int argc, char* argv[])
AFCPluginManager::GetInstancePtr()->CheckConfig();

//back thread, for some cmd
CreateBackThread();
//CreateBackThread();

while(!bExitApp) //DEBUG版本崩溃,RELEASE不崩
while(!bExitApp) //DEBUG版本崩溃,RELEASE不崩
{
while(true)
{
Expand Down

0 comments on commit 101e79c

Please sign in to comment.