Added --cpu-priority option.
This commit is contained in:
parent
61859dfe14
commit
f05a328474
15 changed files with 136 additions and 6 deletions
|
@ -25,7 +25,8 @@
|
|||
#include "workers/Handle.h"
|
||||
|
||||
|
||||
Handle::Handle(int threadId, int threads, int64_t affinity) :
|
||||
Handle::Handle(int threadId, int threads, int64_t affinity, int priority) :
|
||||
m_priority(priority),
|
||||
m_threadId(threadId),
|
||||
m_threads(threads),
|
||||
m_affinity(affinity),
|
||||
|
|
|
@ -35,10 +35,11 @@ class IWorker;
|
|||
class Handle
|
||||
{
|
||||
public:
|
||||
Handle(int threadId, int threads, int64_t affinity);
|
||||
Handle(int threadId, int threads, int64_t affinity, int priority);
|
||||
void join();
|
||||
void start(void (*callback) (void *));
|
||||
|
||||
inline int priority() const { return m_priority; }
|
||||
inline int threadId() const { return m_threadId; }
|
||||
inline int threads() const { return m_threads; }
|
||||
inline int64_t affinity() const { return m_affinity; }
|
||||
|
@ -46,6 +47,7 @@ public:
|
|||
inline void setWorker(IWorker *worker) { m_worker = worker; }
|
||||
|
||||
private:
|
||||
int m_priority;
|
||||
int m_threadId;
|
||||
int m_threads;
|
||||
int64_t m_affinity;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "Cpu.h"
|
||||
#include "Mem.h"
|
||||
#include "Platform.h"
|
||||
#include "workers/Handle.h"
|
||||
#include "workers/Worker.h"
|
||||
|
||||
|
@ -42,6 +43,7 @@ Worker::Worker(Handle *handle) :
|
|||
Cpu::setAffinity(m_id, handle->affinity());
|
||||
}
|
||||
|
||||
Platform::setThreadPriority(handle->priority());
|
||||
m_ctx = Mem::create(m_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void Workers::setJob(const Job &job)
|
|||
}
|
||||
|
||||
|
||||
void Workers::start(int64_t affinity)
|
||||
void Workers::start(int64_t affinity, int priority)
|
||||
{
|
||||
const int threads = Mem::threads();
|
||||
m_hashrate = new Hashrate(threads);
|
||||
|
@ -114,7 +114,7 @@ void Workers::start(int64_t affinity)
|
|||
uv_timer_start(&m_timer, Workers::onTick, 500, 500);
|
||||
|
||||
for (int i = 0; i < threads; ++i) {
|
||||
Handle *handle = new Handle(i, threads, affinity);
|
||||
Handle *handle = new Handle(i, threads, affinity, priority);
|
||||
m_workers.push_back(handle);
|
||||
handle->start(Workers::onReady);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
static void printHashrate(bool detail);
|
||||
static void setEnabled(bool enabled);
|
||||
static void setJob(const Job &job);
|
||||
static void start(int64_t affinity);
|
||||
static void start(int64_t affinity, int priority);
|
||||
static void stop();
|
||||
static void submit(const JobResult &result);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue