mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-16 11:12:47 -05:00
Update net
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
@@ -17,8 +17,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/tools/MemPool.h"
|
||||
#include "base/net/tools/NetBuffer.h"
|
||||
#include "base/kernel/constants.h"
|
||||
#include "base/net/tools/MemPool.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
@@ -28,14 +29,13 @@
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static constexpr size_t kInitSize = 4;
|
||||
static MemPool<NetBuffer::kChunkSize, kInitSize> *pool = nullptr;
|
||||
static MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *pool = nullptr;
|
||||
|
||||
|
||||
inline MemPool<NetBuffer::kChunkSize, kInitSize> *getPool()
|
||||
inline MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS> *getPool()
|
||||
{
|
||||
if (!pool) {
|
||||
pool = new MemPool<NetBuffer::kChunkSize, kInitSize>();
|
||||
pool = new MemPool<XMRIG_NET_BUFFER_CHUNK_SIZE, XMRIG_NET_BUFFER_INIT_CHUNKS>();
|
||||
}
|
||||
|
||||
return pool;
|
||||
@@ -67,17 +67,25 @@ void xmrig::NetBuffer::destroy()
|
||||
void xmrig::NetBuffer::onAlloc(uv_handle_t *, size_t, uv_buf_t *buf)
|
||||
{
|
||||
buf->base = getPool()->allocate();
|
||||
buf->len = kChunkSize;
|
||||
buf->len = XMRIG_NET_BUFFER_CHUNK_SIZE;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const char *buf)
|
||||
{
|
||||
if (buf == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPool()->deallocate(buf);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::NetBuffer::release(const uv_buf_t *buf)
|
||||
{
|
||||
if (buf->base == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPool()->deallocate(buf->base);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user