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

@ -27,9 +27,9 @@
#include "crypto/rx/RxQueue.h"
#include "backend/common/interfaces/IRxListener.h"
#include "base/io/Async.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/tools/Handle.h"
#include "crypto/rx/RxBasicStorage.h"
@ -41,11 +41,7 @@
xmrig::RxQueue::RxQueue(IRxListener *listener) :
m_listener(listener)
{
m_async = new uv_async_t;
m_async->data = this;
uv_async_init(uv_default_loop(), m_async, [](uv_async_t *handle) { static_cast<RxQueue *>(handle->data)->onReady(); });
m_async = std::make_shared<Async>(this);
m_thread = std::thread(&RxQueue::backgroundInit, this);
}
@ -61,8 +57,6 @@ xmrig::RxQueue::~RxQueue()
m_thread.join();
delete m_storage;
Handle::close(m_async);
}
@ -167,7 +161,7 @@ void xmrig::RxQueue::backgroundInit()
}
m_state = STATE_IDLE;
uv_async_send(m_async);
m_async->send();
}
}