Revert "Integrated thread based double hash mode"

This reverts commit e264c5f8b5.
This commit is contained in:
BenDroid 2017-11-30 22:11:58 +01:00
parent 9e3b2e857b
commit 19f0940b92
17 changed files with 133 additions and 160 deletions

View file

@ -28,8 +28,6 @@
#include <string.h>
#include <time.h>
#include "Options.h"
#ifdef WIN32
# include <winsock2.h>
# include <windows.h>
@ -41,18 +39,16 @@
ConsoleLog::ConsoleLog(bool colors) :
m_colors(colors),
m_stream(nullptr)
m_colors(colors),
m_stream(nullptr)
{
if (uv_tty_init(uv_default_loop(), &m_tty, 1, 0) < 0) {
Options::i()->setColors(false);
m_colors = false;
return;
}
uv_tty_set_mode(&m_tty, UV_TTY_MODE_NORMAL);
m_uvBuf.base = m_buf;
m_stream = reinterpret_cast<uv_stream_t*>(&m_tty);
m_stream = reinterpret_cast<uv_stream_t*>(&m_tty);
# ifdef WIN32
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
@ -69,6 +65,10 @@ ConsoleLog::ConsoleLog(bool colors) :
void ConsoleLog::message(int level, const char* fmt, va_list args)
{
if (!isWritable()) {
return;
}
time_t now = time(nullptr);
tm stime;
@ -113,7 +113,7 @@ void ConsoleLog::message(int level, const char* fmt, va_list args)
m_colors ? color : "",
fmt,
m_colors ? Log::kCL_N : ""
);
);
print(args);
}
@ -121,6 +121,10 @@ void ConsoleLog::message(int level, const char* fmt, va_list args)
void ConsoleLog::text(const char* fmt, va_list args)
{
if (!isWritable()) {
return;
}
snprintf(m_fmt, sizeof(m_fmt) - 1, "%s%s\n", fmt, m_colors ? Log::kCL_N : "");
print(args);
@ -145,10 +149,5 @@ void ConsoleLog::print(va_list args)
return;
}
if (!isWritable()) {
fprintf(stdout, m_buf);
fflush(stdout);
} else {
uv_try_write(m_stream, &m_uvBuf, 1);
}
uv_try_write(m_stream, &m_uvBuf, 1);
}