-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle chinese logging library fiasco
- Loading branch information
1 parent
8046bb6
commit 6fe99e8
Showing
12 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
#include <chrono> | ||
#include <lol/common.hpp> | ||
#include <thread> | ||
|
||
using namespace lol; | ||
|
||
#ifdef _WIN32 | ||
extern "C" { | ||
extern void Sleep(unsigned ms); | ||
} | ||
void lol::sleep_ms(std::uint32_t ms) { Sleep(ms); } | ||
#else | ||
void lol::sleep_ms(std::uint32_t ms) { std::this_thread::sleep_for(std::chrono::milliseconds{ms}); } | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,6 @@ | |
#include <span> | ||
#include <utility> | ||
|
||
namespace lol {} | ||
namespace lol { | ||
void sleep_ms(std::uint32_t ms); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <fmtlog-inl.h> | ||
|
||
#include <lol/common.hpp> | ||
#include <lol/log.hpp> | ||
|
||
void lol::init_logging_thread() { | ||
fmtlogDetailWrapper<>::impl.stopPollingThread(); | ||
fmtlogDetailWrapper<>::impl.threadRunning = true; | ||
fmtlogDetailWrapper<>::impl.thr = std::thread([]() { | ||
while (fmtlogDetailWrapper<>::impl.threadRunning) { | ||
fmtlogDetailWrapper<>::impl.poll(false); | ||
// Why are we using our own polling thread instead of builtin one: | ||
// This chinese logging library uses nanoseconds to poll. | ||
// As it turns out windows is utterly incapable of sleeping below 1ms. | ||
// As a consequence std::this_thread_sleep sleeps by doing a busy wait on high precision system clock. | ||
// This absolutely destroys CPU performance on certain machines as it pins the core to 100%. | ||
lol::sleep_ms(1); | ||
} | ||
fmtlogDetailWrapper<>::impl.poll(true); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
#include <fmtlog.h> | ||
|
||
#include <lol/common.hpp> | ||
|
||
namespace lol { | ||
void init_logging_thread(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters