Auto merge of #1972 - str4d:1950-ensure-messages-are-rendered, r=ebfull
Ensure messages are rendered in the metrics UI Part of #1950.
This commit is contained in:
commit
2a18730417
|
@ -20,6 +20,7 @@
|
||||||
CCriticalSection cs_metrics;
|
CCriticalSection cs_metrics;
|
||||||
|
|
||||||
boost::synchronized_value<int64_t> nNodeStartTime;
|
boost::synchronized_value<int64_t> nNodeStartTime;
|
||||||
|
boost::synchronized_value<int64_t> nNextRefresh;
|
||||||
AtomicCounter transactionsValidated;
|
AtomicCounter transactionsValidated;
|
||||||
AtomicCounter ehSolverRuns;
|
AtomicCounter ehSolverRuns;
|
||||||
AtomicCounter solutionTargetChecks;
|
AtomicCounter solutionTargetChecks;
|
||||||
|
@ -60,10 +61,20 @@ double GetLocalSolPS()
|
||||||
return GetLocalSolPS_INTERNAL(GetUptime());
|
return GetLocalSolPS_INTERNAL(GetUptime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerRefresh()
|
||||||
|
{
|
||||||
|
*nNextRefresh = GetTime();
|
||||||
|
// Ensure that the refresh has started before we return
|
||||||
|
MilliSleep(200);
|
||||||
|
}
|
||||||
|
|
||||||
static bool metrics_ThreadSafeMessageBox(const std::string& message,
|
static bool metrics_ThreadSafeMessageBox(const std::string& message,
|
||||||
const std::string& caption,
|
const std::string& caption,
|
||||||
unsigned int style)
|
unsigned int style)
|
||||||
{
|
{
|
||||||
|
// The SECURE flag has no effect in the metrics UI.
|
||||||
|
style &= ~CClientUIInterface::SECURE;
|
||||||
|
|
||||||
std::string strCaption;
|
std::string strCaption;
|
||||||
// Check for usage of predefined caption
|
// Check for usage of predefined caption
|
||||||
switch (style) {
|
switch (style) {
|
||||||
|
@ -85,6 +96,9 @@ static bool metrics_ThreadSafeMessageBox(const std::string& message,
|
||||||
if (u->size() > 5) {
|
if (u->size() > 5) {
|
||||||
u->pop_back();
|
u->pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TriggerRefresh();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void metrics_InitMessage(const std::string& message)
|
static void metrics_InitMessage(const std::string& message)
|
||||||
|
@ -247,8 +261,21 @@ int printMessageBox(size_t cols)
|
||||||
std::cout << _("Messages:") << std::endl;
|
std::cout << _("Messages:") << std::endl;
|
||||||
for (auto it = u->cbegin(); it != u->cend(); ++it) {
|
for (auto it = u->cbegin(); it != u->cend(); ++it) {
|
||||||
std::cout << *it << std::endl;
|
std::cout << *it << std::endl;
|
||||||
// Handle wrapped lines
|
// Handle newlines and wrapped lines
|
||||||
lines += (it->size() / cols);
|
size_t i = 0;
|
||||||
|
size_t j = 0;
|
||||||
|
while (j < it->size()) {
|
||||||
|
i = it->find('\n', j);
|
||||||
|
if (i == std::string::npos) {
|
||||||
|
i = it->size();
|
||||||
|
} else {
|
||||||
|
// Newline
|
||||||
|
lines++;
|
||||||
|
}
|
||||||
|
// Wrapped lines
|
||||||
|
lines += ((i-j) / cols);
|
||||||
|
j = i + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
return lines;
|
return lines;
|
||||||
|
@ -333,8 +360,8 @@ void ThreadShowMetricsScreen()
|
||||||
std::cout << "----------------------------------------" << std::endl;
|
std::cout << "----------------------------------------" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nWaitEnd = GetTime() + nRefresh;
|
*nNextRefresh = GetTime() + nRefresh;
|
||||||
while (GetTime() < nWaitEnd) {
|
while (GetTime() < *nNextRefresh) {
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
MilliSleep(200);
|
MilliSleep(200);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ void TrackMinedBlock(uint256 hash);
|
||||||
void MarkStartTime();
|
void MarkStartTime();
|
||||||
double GetLocalSolPS();
|
double GetLocalSolPS();
|
||||||
|
|
||||||
|
void TriggerRefresh();
|
||||||
|
|
||||||
void ConnectMetricsScreen();
|
void ConnectMetricsScreen();
|
||||||
void ThreadShowMetricsScreen();
|
void ThreadShowMetricsScreen();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue