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

@ -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);