New Async wrapper.

This commit is contained in:
XMRig 2020-10-21 08:09:44 +07:00
parent 6860450147
commit 87b4d97798
No known key found for this signature in database
GPG key ID: 446A53638BE94409
7 changed files with 157 additions and 37 deletions

View file

@ -28,7 +28,7 @@
#define XMRIG_RX_QUEUE_H
#include "base/io/Async.h"
#include "base/kernel/interfaces/IAsyncListener.h"
#include "base/tools/Object.h"
#include "crypto/common/HugePagesInfo.h"
#include "crypto/rx/RxConfig.h"
@ -40,9 +40,6 @@
#include <thread>
using uv_async_t = struct uv_async_s;
namespace xmrig
{
@ -75,19 +72,22 @@ public:
};
class RxQueue
class RxQueue : public IAsyncListener
{
public:
XMRIG_DISABLE_COPY_MOVE(RxQueue);
RxQueue(IRxListener *listener);
~RxQueue();
~RxQueue() override;
HugePagesInfo hugePages();
RxDataset *dataset(const Job &job, uint32_t nodeId);
template<typename T> bool isReady(const T &seed);
void enqueue(const RxSeed &seed, const std::vector<uint32_t> &nodeset, uint32_t threads, bool hugePages, bool oneGbPages, RxConfig::Mode mode, int priority);
protected:
inline void onAsync() override { onReady(); }
private:
enum State {
STATE_IDLE,
@ -105,9 +105,9 @@ private:
State m_state = STATE_IDLE;
std::condition_variable m_cv;
std::mutex m_mutex;
std::shared_ptr<Async> m_async;
std::thread m_thread;
std::vector<RxQueueItem> m_queue;
uv_async_t *m_async = nullptr;
};