Add extra information to threads API.

This commit is contained in:
XMRig 2018-04-17 14:36:32 +07:00
parent c0a72edf9a
commit d04a1fcb8f
4 changed files with 30 additions and 7 deletions

View file

@ -4,8 +4,8 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2017 XMRig <support@xmrig.com>
*
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,8 +38,3 @@ void Cpu::init()
initCommon();
}
void Cpu::setAffinity(int id, uint64_t mask)
{
}

View file

@ -285,6 +285,8 @@ void ApiRouter::getThreads(rapidjson::Document &doc) const
auto &allocator = doc.GetAllocator();
const Hashrate *hr = Workers::hashrate();
Workers::threadsSummary(doc);
const std::vector<xmrig::IThread *> &threads = m_controller->config()->threads();
rapidjson::Value list(rapidjson::kArrayType);

View file

@ -33,6 +33,7 @@
#include "interfaces/IThread.h"
#include "log/Log.h"
#include "Mem.h"
#include "rapidjson/document.h"
#include "workers/Handle.h"
#include "workers/Hashrate.h"
#include "workers/MultiWorker.h"
@ -188,6 +189,26 @@ void Workers::submit(const JobResult &result)
}
#ifndef XMRIG_NO_API
void Workers::threadsSummary(rapidjson::Document &doc)
{
uv_mutex_lock(&m_mutex);
const size_t pages[2] = { m_status.hugePages, m_status.pages };
const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo);
uv_mutex_unlock(&m_mutex);
auto &allocator = doc.GetAllocator();
rapidjson::Value hugepages(rapidjson::kArrayType);
hugepages.PushBack(pages[0], allocator);
hugepages.PushBack(pages[1], allocator);
doc.AddMember("hugepages", hugepages, allocator);
doc.AddMember("memory", memory, allocator);
}
#endif
void Workers::onReady(void *arg)
{
auto handle = static_cast<Handle*>(arg);

View file

@ -32,6 +32,7 @@
#include "net/Job.h"
#include "net/JobResult.h"
#include "rapidjson/fwd.h"
class Handle;
@ -66,6 +67,10 @@ public:
static inline void pause() { m_active = false; m_paused = 1; m_sequence++; }
static inline void setListener(IJobResultListener *listener) { m_listener = listener; }
# ifndef XMRIG_NO_API
static void threadsSummary(rapidjson::Document &doc);
# endif
private:
static void onReady(void *arg);
static void onResult(uv_async_t *handle);