#ifndef BITCOIN_ALLOCATORS_H
#define BITCOIN_ALLOCATORS_H
-#include <string.h>
+#include <openssl/crypto.h> // for OPENSSL_cleanse()
+
+#include <cstring>
#include <string>
-#include <boost/thread/mutex.hpp>
+#include <mutex>
+#include <cassert>
#include <map>
-#include <openssl/crypto.h> // for OPENSSL_cleanse()
#ifdef WIN32
#ifdef _WIN32_WINNT
// the pagefile except in rare circumstances where memory is extremely low.
#else
#include <sys/mman.h>
-#include <limits.h> // for PAGESIZE
+#include <climits> // for PAGESIZE
#include <unistd.h> // for sysconf
#endif
// For all pages in affected range, increase lock count
void LockRange(void *p, size_t size)
{
- boost::mutex::scoped_lock lock(mutex);
+ std::scoped_lock lock(mutex);
if(!size) return;
const size_t base_addr = reinterpret_cast<size_t>(p);
const size_t start_page = base_addr & page_mask;
// For all pages in affected range, decrease lock count
void UnlockRange(void *p, size_t size)
{
- boost::mutex::scoped_lock lock(mutex);
+ std::scoped_lock lock(mutex);
if(!size) return;
const size_t base_addr = reinterpret_cast<size_t>(p);
const size_t start_page = base_addr & page_mask;
// Get number of locked pages for diagnostics
int GetLockedPageCount()
{
- boost::mutex::scoped_lock lock(mutex);
+ std::scoped_lock lock(mutex);
return histogram.size();
}
private:
Locker locker;
- boost::mutex mutex;
+ std::mutex mutex;
size_t page_size, page_mask;
// map of page base address to lock count
typedef std::map<size_t,int> Histogram;