mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Simplify Beast:
* Remove obsolete RNG facilities * Flatten directory structure * Use std::recursive_mutex instead of beast::RecursiveMutex
This commit is contained in:
@@ -653,11 +653,6 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\core\logging\Logger.h">
|
<ClInclude Include="..\..\src\beast\beast\module\core\logging\Logger.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\core\maths\Random.cpp">
|
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\core\maths\Random.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\core\memory\MemoryBlock.cpp">
|
<ClCompile Include="..\..\src\beast\beast\module\core\memory\MemoryBlock.cpp">
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -861,9 +856,7 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\nudb\win32_file.h">
|
<ClInclude Include="..\..\src\beast\beast\nudb\win32_file.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\random\rngfill.h">
|
<ClInclude Include="..\..\src\beast\beast\rngfill.h">
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\random\xor_shift_engine.h">
|
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\SmartPtr.h">
|
<ClInclude Include="..\..\src\beast\beast\SmartPtr.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -918,9 +911,6 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\beast\beast\Threads.h">
|
<ClInclude Include="..\..\src\beast\beast\Threads.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\RecursiveMutex.cpp">
|
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\Stoppable.cpp">
|
<ClCompile Include="..\..\src\beast\beast\threads\impl\Stoppable.cpp">
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -933,8 +923,6 @@
|
|||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\WaitableEvent.cpp">
|
<ClCompile Include="..\..\src\beast\beast\threads\impl\WaitableEvent.cpp">
|
||||||
<ExcludedFromBuild>True</ExcludedFromBuild>
|
<ExcludedFromBuild>True</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\beast\beast\threads\RecursiveMutex.h">
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\threads\ScopedWrapperContext.h">
|
<ClInclude Include="..\..\src\beast\beast\threads\ScopedWrapperContext.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\threads\semaphore.h">
|
<ClInclude Include="..\..\src\beast\beast\threads\semaphore.h">
|
||||||
@@ -1049,6 +1037,8 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\win32_workaround.h">
|
<ClInclude Include="..\..\src\beast\beast\win32_workaround.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\beast\beast\xor_shift_engine.h">
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-64bit.h">
|
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-64bit.h">
|
||||||
|
|||||||
@@ -103,9 +103,6 @@
|
|||||||
<Filter Include="beast\module\core\logging">
|
<Filter Include="beast\module\core\logging">
|
||||||
<UniqueIdentifier>{E2E1AA2E-7817-DCA7-66A3-DBC4BAB06D5C}</UniqueIdentifier>
|
<UniqueIdentifier>{E2E1AA2E-7817-DCA7-66A3-DBC4BAB06D5C}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="beast\module\core\maths">
|
|
||||||
<UniqueIdentifier>{85C3F5F1-0A60-FF1F-2FE4-AD0868832D6B}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="beast\module\core\memory">
|
<Filter Include="beast\module\core\memory">
|
||||||
<UniqueIdentifier>{EE59B06D-092E-4C80-21B1-3781040C8FF3}</UniqueIdentifier>
|
<UniqueIdentifier>{EE59B06D-092E-4C80-21B1-3781040C8FF3}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -154,9 +151,6 @@
|
|||||||
<Filter Include="beast\nudb\tests">
|
<Filter Include="beast\nudb\tests">
|
||||||
<UniqueIdentifier>{ACEF9E32-BEA2-86E3-BDE3-E772564EA55B}</UniqueIdentifier>
|
<UniqueIdentifier>{ACEF9E32-BEA2-86E3-BDE3-E772564EA55B}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="beast\random">
|
|
||||||
<UniqueIdentifier>{94B0990A-9ABE-B1EC-C220-83FD8C2F529F}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="beast\smart_ptr">
|
<Filter Include="beast\smart_ptr">
|
||||||
<UniqueIdentifier>{C8013957-E624-4A24-C0F8-CBAAC144AF09}</UniqueIdentifier>
|
<UniqueIdentifier>{C8013957-E624-4A24-C0F8-CBAAC144AF09}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -1206,12 +1200,6 @@
|
|||||||
<ClInclude Include="..\..\src\beast\beast\module\core\logging\Logger.h">
|
<ClInclude Include="..\..\src\beast\beast\module\core\logging\Logger.h">
|
||||||
<Filter>beast\module\core\logging</Filter>
|
<Filter>beast\module\core\logging</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\core\maths\Random.cpp">
|
|
||||||
<Filter>beast\module\core\maths</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\module\core\maths\Random.h">
|
|
||||||
<Filter>beast\module\core\maths</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\module\core\memory\MemoryBlock.cpp">
|
<ClCompile Include="..\..\src\beast\beast\module\core\memory\MemoryBlock.cpp">
|
||||||
<Filter>beast\module\core\memory</Filter>
|
<Filter>beast\module\core\memory</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -1470,11 +1458,8 @@
|
|||||||
<ClInclude Include="..\..\src\beast\beast\nudb\win32_file.h">
|
<ClInclude Include="..\..\src\beast\beast\nudb\win32_file.h">
|
||||||
<Filter>beast\nudb</Filter>
|
<Filter>beast\nudb</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\random\rngfill.h">
|
<ClInclude Include="..\..\src\beast\beast\rngfill.h">
|
||||||
<Filter>beast\random</Filter>
|
<Filter>beast</Filter>
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\random\xor_shift_engine.h">
|
|
||||||
<Filter>beast\random</Filter>
|
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\beast\beast\SmartPtr.h">
|
<ClInclude Include="..\..\src\beast\beast\SmartPtr.h">
|
||||||
<Filter>beast</Filter>
|
<Filter>beast</Filter>
|
||||||
@@ -1548,9 +1533,6 @@
|
|||||||
<ClInclude Include="..\..\src\beast\beast\Threads.h">
|
<ClInclude Include="..\..\src\beast\beast\Threads.h">
|
||||||
<Filter>beast</Filter>
|
<Filter>beast</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\RecursiveMutex.cpp">
|
|
||||||
<Filter>beast\threads\impl</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\Stoppable.cpp">
|
<ClCompile Include="..\..\src\beast\beast\threads\impl\Stoppable.cpp">
|
||||||
<Filter>beast\threads\impl</Filter>
|
<Filter>beast\threads\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -1563,9 +1545,6 @@
|
|||||||
<ClCompile Include="..\..\src\beast\beast\threads\impl\WaitableEvent.cpp">
|
<ClCompile Include="..\..\src\beast\beast\threads\impl\WaitableEvent.cpp">
|
||||||
<Filter>beast\threads\impl</Filter>
|
<Filter>beast\threads\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClInclude Include="..\..\src\beast\beast\threads\RecursiveMutex.h">
|
|
||||||
<Filter>beast\threads</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\beast\beast\threads\ScopedWrapperContext.h">
|
<ClInclude Include="..\..\src\beast\beast\threads\ScopedWrapperContext.h">
|
||||||
<Filter>beast\threads</Filter>
|
<Filter>beast\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1719,6 +1698,9 @@
|
|||||||
<ClInclude Include="..\..\src\beast\beast\win32_workaround.h">
|
<ClInclude Include="..\..\src\beast\beast\win32_workaround.h">
|
||||||
<Filter>beast</Filter>
|
<Filter>beast</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\beast\beast\xor_shift_engine.h">
|
||||||
|
<Filter>beast</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
<ClInclude Include="..\..\src\ed25519-donna\curve25519-donna-32bit.h">
|
||||||
<Filter>ed25519-donna</Filter>
|
<Filter>ed25519-donna</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@@ -39,9 +39,11 @@ public:
|
|||||||
static beast::endian const endian =
|
static beast::endian const endian =
|
||||||
beast::endian::native;
|
beast::endian::native;
|
||||||
|
|
||||||
|
static std::size_t const digest_size =
|
||||||
|
Context::digest_size;
|
||||||
|
|
||||||
using result_type =
|
using result_type =
|
||||||
std::array<std::uint8_t,
|
std::array<std::uint8_t, digest_size>;
|
||||||
Context::digest_size>;
|
|
||||||
|
|
||||||
mac_facade() noexcept
|
mac_facade() noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
#include <beast/container/fnv1a.h>
|
#include <beast/container/fnv1a.h>
|
||||||
#include <beast/container/siphash.h>
|
#include <beast/container/siphash.h>
|
||||||
#include <beast/container/xxhasher.h>
|
#include <beast/container/xxhasher.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <beast/hash/tests/hash_metrics.h>
|
#include <beast/hash/tests/hash_metrics.h>
|
||||||
#include <beast/hash/hash_append.h>
|
#include <beast/hash/hash_append.h>
|
||||||
#include <beast/chrono/chrono_io.h>
|
#include <beast/chrono/chrono_io.h>
|
||||||
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/utility/type_name.h>
|
#include <beast/utility/type_name.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
@@ -284,7 +285,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
SlowKey()
|
SlowKey()
|
||||||
{
|
{
|
||||||
static std::mt19937_64 eng;
|
static beast::xor_shift_engine eng;
|
||||||
std::uniform_int_distribution<short> yeardata(1900, 2014);
|
std::uniform_int_distribution<short> yeardata(1900, 2014);
|
||||||
std::uniform_int_distribution<unsigned> monthdata(1, 12);
|
std::uniform_int_distribution<unsigned> monthdata(1, 12);
|
||||||
std::uniform_int_distribution<unsigned> daydata(1, 28);
|
std::uniform_int_distribution<unsigned> daydata(1, 28);
|
||||||
@@ -331,8 +332,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
FastKey()
|
FastKey()
|
||||||
{
|
{
|
||||||
static std::conditional_t <sizeof(std::size_t)==sizeof(std::uint64_t),
|
static beast::xor_shift_engine eng;
|
||||||
std::mt19937_64, std::mt19937> eng;
|
|
||||||
for (auto& v : m_values)
|
for (auto& v : m_values)
|
||||||
v = eng();
|
v = eng();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
#include <beast/hash/siphash.h>
|
#include <beast/hash/siphash.h>
|
||||||
#include <beast/hash/xxhasher.h>
|
#include <beast/hash/xxhasher.h>
|
||||||
#include <beast/chrono/chrono_io.h>
|
#include <beast/chrono/chrono_io.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class FileOutputStream;
|
|||||||
#include <beast/module/core/diagnostic/FatalError.h>
|
#include <beast/module/core/diagnostic/FatalError.h>
|
||||||
#include <beast/module/core/text/LexicalCast.h>
|
#include <beast/module/core/text/LexicalCast.h>
|
||||||
#include <beast/module/core/logging/Logger.h>
|
#include <beast/module/core/logging/Logger.h>
|
||||||
#include <beast/module/core/maths/Random.h>
|
|
||||||
#include <beast/module/core/text/StringPairArray.h>
|
#include <beast/module/core/text/StringPairArray.h>
|
||||||
#include <beast/module/core/files/DirectoryIterator.h>
|
#include <beast/module/core/files/DirectoryIterator.h>
|
||||||
#include <beast/module/core/streams/InputStream.h>
|
#include <beast/module/core/streams/InputStream.h>
|
||||||
|
|||||||
@@ -139,8 +139,6 @@
|
|||||||
#include <beast/module/core/files/FileInputStream.cpp>
|
#include <beast/module/core/files/FileInputStream.cpp>
|
||||||
#include <beast/module/core/files/FileOutputStream.cpp>
|
#include <beast/module/core/files/FileOutputStream.cpp>
|
||||||
|
|
||||||
#include <beast/module/core/maths/Random.cpp>
|
|
||||||
|
|
||||||
#include <beast/module/core/memory/MemoryBlock.cpp>
|
#include <beast/module/core/memory/MemoryBlock.cpp>
|
||||||
|
|
||||||
#include <beast/module/core/misc/Result.cpp>
|
#include <beast/module/core/misc/Result.cpp>
|
||||||
|
|||||||
@@ -21,87 +21,10 @@
|
|||||||
#define BEAST_MODULE_CORE_DIAGNOSTIC_UNITTESTUTILITIES_H_INCLUDED
|
#define BEAST_MODULE_CORE_DIAGNOSTIC_UNITTESTUTILITIES_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/module/core/files/File.h>
|
#include <beast/module/core/files/File.h>
|
||||||
#include <beast/module/core/maths/Random.h>
|
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace UnitTestUtilities {
|
namespace UnitTestUtilities {
|
||||||
|
|
||||||
/** Fairly shuffle an array pseudo-randomly.
|
|
||||||
*/
|
|
||||||
template <class T>
|
|
||||||
void repeatableShuffle (int const numberOfItems, T& arrayOfItems, Random& r)
|
|
||||||
{
|
|
||||||
for (int i = numberOfItems - 1; i > 0; --i)
|
|
||||||
{
|
|
||||||
int const choice = r.nextInt (i + 1);
|
|
||||||
std::swap (arrayOfItems [i], arrayOfItems [choice]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void repeatableShuffle (int const numberOfItems, T& arrayOfItems, std::int64_t seedValue)
|
|
||||||
{
|
|
||||||
Random r (seedValue);
|
|
||||||
repeatableShuffle (numberOfItems, arrayOfItems, r);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/** A block of memory used for test data.
|
|
||||||
*/
|
|
||||||
struct Payload
|
|
||||||
{
|
|
||||||
/** Construct a payload with a buffer of the specified maximum size.
|
|
||||||
|
|
||||||
@param maximumBytes The size of the buffer, in bytes.
|
|
||||||
*/
|
|
||||||
explicit Payload (int maxBufferSize)
|
|
||||||
: bufferSize (maxBufferSize)
|
|
||||||
, data (maxBufferSize)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Generate a random block of data within a certain size range.
|
|
||||||
|
|
||||||
@param minimumBytes The smallest number of bytes in the resulting payload.
|
|
||||||
@param maximumBytes The largest number of bytes in the resulting payload.
|
|
||||||
@param seedValue The value to seed the random number generator with.
|
|
||||||
*/
|
|
||||||
void repeatableRandomFill (int minimumBytes, int maximumBytes, std::int64_t seedValue) noexcept
|
|
||||||
{
|
|
||||||
bassert (minimumBytes >=0 && maximumBytes <= bufferSize);
|
|
||||||
|
|
||||||
Random r (seedValue);
|
|
||||||
|
|
||||||
bytes = minimumBytes + r.nextInt (1 + maximumBytes - minimumBytes);
|
|
||||||
|
|
||||||
bassert (bytes >= minimumBytes && bytes <= bufferSize);
|
|
||||||
|
|
||||||
for (int i = 0; i < bytes; ++i)
|
|
||||||
data [i] = static_cast <unsigned char> (r.nextInt ());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Compare two payloads for equality.
|
|
||||||
*/
|
|
||||||
bool operator== (Payload const& other) const noexcept
|
|
||||||
{
|
|
||||||
if (bytes == other.bytes)
|
|
||||||
{
|
|
||||||
return memcmp (data.getData (), other.data.getData (), bytes) == 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
int const bufferSize;
|
|
||||||
|
|
||||||
int bytes;
|
|
||||||
HeapBlock <char> data;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TempDirectory
|
class TempDirectory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
@@ -512,12 +513,17 @@ bool File::appendText (const String& text,
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
File File::createTempFile (const String& fileNameEnding)
|
File File::createTempFile (const String& fileNameEnding)
|
||||||
{
|
{
|
||||||
const File tempFile (getSpecialLocation (tempDirectory)
|
auto const tempDir = getSpecialLocation (tempDirectory);
|
||||||
.getChildFile ("temp_" + String::toHexString (Random::getSystemRandom().nextInt()))
|
std::random_device rng;
|
||||||
.withFileExtension (fileNameEnding));
|
File tempFile;
|
||||||
|
|
||||||
if (tempFile.exists())
|
do
|
||||||
return createTempFile (fileNameEnding);
|
{
|
||||||
|
tempFile = tempDir.getChildFile (
|
||||||
|
"temp_" + std::to_string(rng()))
|
||||||
|
.withFileExtension (fileNameEnding);
|
||||||
|
}
|
||||||
|
while (tempFile.exists());
|
||||||
|
|
||||||
return tempFile;
|
return tempFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,152 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Portions of this file are from JUCE.
|
|
||||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
||||||
Please visit http://www.juce.com
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <beast/unit_test/suite.h>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
Random::Random (const std::int64_t seedValue) noexcept
|
|
||||||
: seed (seedValue)
|
|
||||||
{
|
|
||||||
nextInt (); // fixes a bug where the first int is always 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Random::Random()
|
|
||||||
: seed (1)
|
|
||||||
{
|
|
||||||
setSeedRandomly();
|
|
||||||
}
|
|
||||||
|
|
||||||
Random::~Random() noexcept
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Random::setSeed (const std::int64_t newSeed) noexcept
|
|
||||||
{
|
|
||||||
seed = newSeed;
|
|
||||||
|
|
||||||
nextInt (); // fixes a bug where the first int is always 0
|
|
||||||
}
|
|
||||||
|
|
||||||
void Random::combineSeed (const std::int64_t seedValue) noexcept
|
|
||||||
{
|
|
||||||
seed ^= nextInt64() ^ seedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Random::setSeedRandomly()
|
|
||||||
{
|
|
||||||
static std::int64_t globalSeed = 0;
|
|
||||||
|
|
||||||
combineSeed (globalSeed ^ (std::int64_t) (std::intptr_t) this);
|
|
||||||
combineSeed (Time::currentTimeMillis());
|
|
||||||
globalSeed ^= seed;
|
|
||||||
|
|
||||||
nextInt (); // fixes a bug where the first int is always 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Random& Random::getSystemRandom() noexcept
|
|
||||||
{
|
|
||||||
static Random sysRand;
|
|
||||||
return sysRand;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
int Random::nextInt() noexcept
|
|
||||||
{
|
|
||||||
seed = (seed * 0x5deece66dLL + 11) & 0xffffffffffffULL;
|
|
||||||
|
|
||||||
return (int) (seed >> 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Random::nextInt (const int maxValue) noexcept
|
|
||||||
{
|
|
||||||
bassert (maxValue > 0);
|
|
||||||
return (int) ((((unsigned int) nextInt()) * (std::uint64_t) maxValue) >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::int64_t Random::nextInt64() noexcept
|
|
||||||
{
|
|
||||||
return (((std::int64_t) nextInt()) << 32) | (std::int64_t) (std::uint64_t) (std::uint32_t) nextInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Random::nextBool() noexcept
|
|
||||||
{
|
|
||||||
return (nextInt() & 0x40000000) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Random::nextFloat() noexcept
|
|
||||||
{
|
|
||||||
return static_cast <std::uint32_t> (nextInt()) / (float) 0xffffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Random::nextDouble() noexcept
|
|
||||||
{
|
|
||||||
return static_cast <std::uint32_t> (nextInt()) / (double) 0xffffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Random::fillBitsRandomly (void* const buffer, size_t bytes)
|
|
||||||
{
|
|
||||||
int* d = static_cast<int*> (buffer);
|
|
||||||
|
|
||||||
for (; bytes >= sizeof (int); bytes -= sizeof (int))
|
|
||||||
*d++ = nextInt();
|
|
||||||
|
|
||||||
if (bytes > 0)
|
|
||||||
{
|
|
||||||
const int lastBytes = nextInt();
|
|
||||||
memcpy (d, &lastBytes, bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
class Random_test : public unit_test::suite
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void run()
|
|
||||||
{
|
|
||||||
for (int j = 10; --j >= 0;)
|
|
||||||
{
|
|
||||||
Random r;
|
|
||||||
r.setSeedRandomly();
|
|
||||||
|
|
||||||
for (int i = 20; --i >= 0;)
|
|
||||||
{
|
|
||||||
expect (r.nextDouble() >= 0.0 && r.nextDouble() < 1.0);
|
|
||||||
expect (r.nextFloat() >= 0.0f && r.nextFloat() < 1.0f);
|
|
||||||
expect (r.nextInt (5) >= 0 && r.nextInt (5) < 5);
|
|
||||||
expect (r.nextInt (1) == 0);
|
|
||||||
|
|
||||||
int n = r.nextInt (50) + 1;
|
|
||||||
expect (r.nextInt (n) >= 0 && r.nextInt (n) < n);
|
|
||||||
|
|
||||||
n = r.nextInt (0x7ffffffe) + 1;
|
|
||||||
expect (r.nextInt (n) >= 0 && r.nextInt (n) < n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
BEAST_DEFINE_TESTSUITE(Random,beast_core,beast);
|
|
||||||
|
|
||||||
} // beast
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Portions of this file are from JUCE.
|
|
||||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
||||||
Please visit http://www.juce.com
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_CORE_MATHS_RANDOM_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_CORE_MATHS_RANDOM_H_INCLUDED
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
/**
|
|
||||||
A random number generator.
|
|
||||||
|
|
||||||
You can create a Random object and use it to generate a sequence of random numbers.
|
|
||||||
*/
|
|
||||||
class Random
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//==============================================================================
|
|
||||||
/** Creates a Random object based on a seed value.
|
|
||||||
|
|
||||||
For a given seed value, the subsequent numbers generated by this object
|
|
||||||
will be predictable, so a good idea is to set this value based
|
|
||||||
on the time, e.g.
|
|
||||||
|
|
||||||
new Random (Time::currentTimeMillis())
|
|
||||||
*/
|
|
||||||
explicit Random (std::int64_t seedValue) noexcept;
|
|
||||||
|
|
||||||
/** Creates a Random object using a random seed value.
|
|
||||||
Internally, this calls setSeedRandomly() to randomise the seed.
|
|
||||||
*/
|
|
||||||
Random();
|
|
||||||
|
|
||||||
/** Destructor. */
|
|
||||||
~Random() noexcept;
|
|
||||||
|
|
||||||
/** Returns the next random 32 bit integer.
|
|
||||||
|
|
||||||
@returns a random integer from the full range 0x80000000 to 0x7fffffff
|
|
||||||
*/
|
|
||||||
int nextInt() noexcept;
|
|
||||||
|
|
||||||
/** Returns the next random number, limited to a given range.
|
|
||||||
The maxValue parameter may not be negative, or zero.
|
|
||||||
@returns a random integer between 0 (inclusive) and maxValue (exclusive).
|
|
||||||
*/
|
|
||||||
int nextInt (int maxValue) noexcept;
|
|
||||||
|
|
||||||
/** Returns the next 64-bit random number.
|
|
||||||
|
|
||||||
@returns a random integer from the full range 0x8000000000000000 to 0x7fffffffffffffff
|
|
||||||
*/
|
|
||||||
std::int64_t nextInt64() noexcept;
|
|
||||||
|
|
||||||
/** Returns the next random floating-point number.
|
|
||||||
|
|
||||||
@returns a random value in the range 0 to 1.0
|
|
||||||
*/
|
|
||||||
float nextFloat() noexcept;
|
|
||||||
|
|
||||||
/** Returns the next random floating-point number.
|
|
||||||
|
|
||||||
@returns a random value in the range 0 to 1.0
|
|
||||||
*/
|
|
||||||
double nextDouble() noexcept;
|
|
||||||
|
|
||||||
/** Returns the next random boolean value.
|
|
||||||
*/
|
|
||||||
bool nextBool() noexcept;
|
|
||||||
|
|
||||||
/** Fills a block of memory with random values. */
|
|
||||||
void fillBitsRandomly (void* bufferToFill, size_t sizeInBytes);
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
/** Resets this Random object to a given seed value. */
|
|
||||||
void setSeed (std::int64_t newSeed) noexcept;
|
|
||||||
|
|
||||||
/** Merges this object's seed with another value.
|
|
||||||
This sets the seed to be a value created by combining the current seed and this
|
|
||||||
new value.
|
|
||||||
*/
|
|
||||||
void combineSeed (std::int64_t seedValue) noexcept;
|
|
||||||
|
|
||||||
/** Reseeds this generator using a value generated from various semi-random system
|
|
||||||
properties like the current time, etc.
|
|
||||||
|
|
||||||
Because this function convolves the time with the last seed value, calling
|
|
||||||
it repeatedly will increase the randomness of the final result.
|
|
||||||
*/
|
|
||||||
void setSeedRandomly();
|
|
||||||
|
|
||||||
/** The overhead of creating a new Random object is fairly small, but if you want to avoid
|
|
||||||
it, you can call this method to get a global shared Random object.
|
|
||||||
|
|
||||||
It's not thread-safe though, so threads should use their own Random object, otherwise
|
|
||||||
you run the risk of your random numbers becoming.. erm.. randomly corrupted..
|
|
||||||
*/
|
|
||||||
static Random& getSystemRandom() noexcept;
|
|
||||||
|
|
||||||
private:
|
|
||||||
//==============================================================================
|
|
||||||
std::int64_t seed;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif // BEAST_RANDOM_H_INCLUDED
|
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
|
#include <beast/xor_shift_engine.h>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
@@ -25,9 +26,9 @@ class LexicalCast_test : public unit_test::suite
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <class IntType>
|
template <class IntType>
|
||||||
static IntType nextRandomInt (Random& r)
|
static IntType nextRandomInt (xor_shift_engine& r)
|
||||||
{
|
{
|
||||||
return static_cast <IntType> (r.nextInt64 ());
|
return static_cast <IntType> (r());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class IntType>
|
template <class IntType>
|
||||||
@@ -42,7 +43,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class IntType>
|
template <class IntType>
|
||||||
void testIntegers (Random& r)
|
void testIntegers (xor_shift_engine& r)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@@ -254,7 +255,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::int64_t const seedValue = 50;
|
std::int64_t const seedValue = 50;
|
||||||
|
|
||||||
Random r (seedValue);
|
xor_shift_engine r (seedValue);
|
||||||
|
|
||||||
testIntegers <int> (r);
|
testIntegers <int> (r);
|
||||||
testIntegers <unsigned int> (r);
|
testIntegers <unsigned int> (r);
|
||||||
|
|||||||
@@ -1,275 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_MODULE_CORE_THREAD_DETAIL_SCOPEDLOCK_H_INCLUDED
|
|
||||||
#define BEAST_MODULE_CORE_THREAD_DETAIL_SCOPEDLOCK_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/module/beast_core/thread/MutexTraits.h>
|
|
||||||
|
|
||||||
namespace beast
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class TrackedScopedLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline explicit TrackedScopedLock (Mutex const& mutex,
|
|
||||||
char const* fileName, int lineNumber) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_lock_count (0)
|
|
||||||
{
|
|
||||||
lock (fileName, lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackedScopedLock (TrackedScopedLock const&) = delete;
|
|
||||||
TrackedScopedLock& operator= (TrackedScopedLock const&) = delete;
|
|
||||||
|
|
||||||
inline ~TrackedScopedLock () noexcept
|
|
||||||
{
|
|
||||||
if (m_lock_count > 0)
|
|
||||||
unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void lock (char const* fileName, int lineNumber) noexcept
|
|
||||||
{
|
|
||||||
++m_lock_count;
|
|
||||||
m_mutex.lock (fileName, lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void unlock () noexcept
|
|
||||||
{
|
|
||||||
m_mutex.unlock ();
|
|
||||||
--m_lock_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
int m_lock_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class TrackedScopedTryLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline explicit TrackedScopedTryLock (Mutex const& mutex,
|
|
||||||
char const* fileName, int lineNumber) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_lock_count (0)
|
|
||||||
{
|
|
||||||
try_lock (fileName, lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackedScopedTryLock (TrackedScopedTryLock const&) = delete;
|
|
||||||
TrackedScopedTryLock& operator= (TrackedScopedTryLock const&) = delete;
|
|
||||||
|
|
||||||
inline ~TrackedScopedTryLock () noexcept
|
|
||||||
{
|
|
||||||
if (m_lock_count > 0)
|
|
||||||
unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool owns_lock () const noexcept
|
|
||||||
{
|
|
||||||
return m_lock_count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool try_lock (char const* fileName, int lineNumber) noexcept
|
|
||||||
{
|
|
||||||
bool const success = m_mutex.try_lock (fileName, lineNumber);
|
|
||||||
if (success)
|
|
||||||
++m_lock_count;
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void unlock () noexcept
|
|
||||||
{
|
|
||||||
m_mutex.unlock ();
|
|
||||||
--m_lock_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
int m_lock_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class TrackedScopedUnlock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline explicit TrackedScopedUnlock (Mutex const& mutex,
|
|
||||||
char const* fileName, int lineNumber) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_fileName (fileName)
|
|
||||||
, m_lineNumber (lineNumber)
|
|
||||||
{
|
|
||||||
m_mutex.unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackedScopedUnlock (TrackedScopedUnlock const&) = delete;
|
|
||||||
TrackedScopedUnlock& operator= (TrackedScopedUnlock const&) = delete;
|
|
||||||
|
|
||||||
inline ~TrackedScopedUnlock () noexcept
|
|
||||||
{
|
|
||||||
m_mutex.lock (m_fileName, m_lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
char const* const m_fileName;
|
|
||||||
int const m_lineNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class UntrackedScopedLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline explicit UntrackedScopedLock (Mutex const& mutex,
|
|
||||||
char const*, int) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_lock_count (0)
|
|
||||||
{
|
|
||||||
lock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
UntrackedScopedLock (UntrackedScopedLock const&) = delete;
|
|
||||||
UntrackedScopedLock& operator= (UntrackedScopedLock const&) = delete;
|
|
||||||
|
|
||||||
inline ~UntrackedScopedLock () noexcept
|
|
||||||
{
|
|
||||||
if (m_lock_count > 0)
|
|
||||||
unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void lock () noexcept
|
|
||||||
{
|
|
||||||
++m_lock_count;
|
|
||||||
m_mutex.lock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void lock (char const*, int) noexcept
|
|
||||||
{
|
|
||||||
lock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void unlock () noexcept
|
|
||||||
{
|
|
||||||
m_mutex.unlock ();
|
|
||||||
--m_lock_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
int m_lock_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class UntrackedScopedTryLock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
inline explicit UntrackedScopedTryLock (Mutex const& mutex,
|
|
||||||
char const*, int) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_lock_count (0)
|
|
||||||
{
|
|
||||||
try_lock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
UntrackedScopedTryLock (UntrackedScopedTryLock const&) = delete;
|
|
||||||
UntrackedScopedTryLock& operator= (UntrackedScopedTryLock const&) = delete;
|
|
||||||
|
|
||||||
inline ~UntrackedScopedTryLock () noexcept
|
|
||||||
{
|
|
||||||
if (m_lock_count > 0)
|
|
||||||
unlock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool owns_lock () const noexcept
|
|
||||||
{
|
|
||||||
return m_lock_count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool try_lock () noexcept
|
|
||||||
{
|
|
||||||
bool const success = m_mutex.try_lock ();
|
|
||||||
if (success)
|
|
||||||
++m_lock_count;
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool try_lock (char const*, int) noexcept
|
|
||||||
{
|
|
||||||
return try_lock ();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void unlock () noexcept
|
|
||||||
{
|
|
||||||
m_mutex.unlock ();
|
|
||||||
--m_lock_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
int m_lock_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class UntrackedScopedUnlock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
UntrackedScopedUnlock (Mutex const& mutex,
|
|
||||||
char const*, int) noexcept
|
|
||||||
: m_mutex (mutex)
|
|
||||||
, m_owns_lock (true)
|
|
||||||
{
|
|
||||||
MutexTraits <Mutex>::unlock (m_mutex);
|
|
||||||
m_owns_lock = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UntrackedScopedUnlock (UntrackedScopedUnlock const&) = delete;
|
|
||||||
UntrackedScopedUnlock& operator= (UntrackedScopedUnlock const&) = delete;
|
|
||||||
|
|
||||||
~UntrackedScopedUnlock () noexcept
|
|
||||||
{
|
|
||||||
MutexTraits <Mutex>::lock (m_mutex);
|
|
||||||
m_owns_lock = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex const& m_mutex;
|
|
||||||
bool m_owns_lock;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
} // beast
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <beast/nudb/tests/common.h>
|
#include <beast/nudb/tests/common.h>
|
||||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||||
#include <beast/module/core/files/File.h>
|
#include <beast/module/core/files/File.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <beast/nudb/identity.h>
|
#include <beast/nudb/identity.h>
|
||||||
#include <beast/nudb/tests/fail_file.h>
|
#include <beast/nudb/tests/fail_file.h>
|
||||||
#include <beast/hash/xxhasher.h>
|
#include <beast/hash/xxhasher.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <beast/nudb/tests/common.h>
|
#include <beast/nudb/tests/common.h>
|
||||||
#include <beast/module/core/files/File.h>
|
#include <beast/module/core/files/File.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include <beast/nudb/tests/common.h>
|
#include <beast/nudb/tests/common.h>
|
||||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||||
#include <beast/module/core/files/File.h>
|
#include <beast/module/core/files/File.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Portions of this file are from JUCE.
|
|
||||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
||||||
Please visit http://www.juce.com
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#ifndef BEAST_THREADS_RECURSIVEMUTEX_H_INCLUDED
|
|
||||||
#define BEAST_THREADS_RECURSIVEMUTEX_H_INCLUDED
|
|
||||||
|
|
||||||
#include <beast/Config.h>
|
|
||||||
#include <beast/threads/UnlockGuard.h>
|
|
||||||
#include <beast/threads/TryLockGuard.h>
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#if ! BEAST_WINDOWS
|
|
||||||
#include <pthread.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
class RecursiveMutex
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using ScopedLockType = std::lock_guard <RecursiveMutex>;
|
|
||||||
using ScopedUnlockType = UnlockGuard <RecursiveMutex>;
|
|
||||||
using ScopedTryLockType = TryLockGuard <RecursiveMutex>;
|
|
||||||
|
|
||||||
/** Create the mutex.
|
|
||||||
The mutux is initially unowned.
|
|
||||||
*/
|
|
||||||
RecursiveMutex ();
|
|
||||||
|
|
||||||
/** Destroy the mutex.
|
|
||||||
If the lock is owned, the result is undefined.
|
|
||||||
*/
|
|
||||||
~RecursiveMutex ();
|
|
||||||
|
|
||||||
// Boost concept compatibility:
|
|
||||||
// http://www.boost.org/doc/libs/1_54_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts
|
|
||||||
|
|
||||||
/** BasicLockable */
|
|
||||||
/** @{ */
|
|
||||||
void lock () const;
|
|
||||||
void unlock () const;
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/** Lockable */
|
|
||||||
bool try_lock () const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// To avoid including windows.h in the public Beast headers, we'll just
|
|
||||||
// reserve storage here that's big enough to be used internally as a windows
|
|
||||||
// CRITICAL_SECTION structure.
|
|
||||||
#if BEAST_WINDOWS
|
|
||||||
# if BEAST_64BIT
|
|
||||||
char section[44];
|
|
||||||
# else
|
|
||||||
char section[24];
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
mutable pthread_mutex_t mutex;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
#ifndef BEAST_THREADS_THREAD_H_INCLUDED
|
#ifndef BEAST_THREADS_THREAD_H_INCLUDED
|
||||||
#define BEAST_THREADS_THREAD_H_INCLUDED
|
#define BEAST_THREADS_THREAD_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/threads/RecursiveMutex.h>
|
|
||||||
#include <beast/threads/WaitableEvent.h>
|
#include <beast/threads/WaitableEvent.h>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -168,7 +168,7 @@ private:
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
std::string const threadName;
|
std::string const threadName;
|
||||||
void* volatile threadHandle;
|
void* volatile threadHandle;
|
||||||
RecursiveMutex startStopLock;
|
std::recursive_mutex startStopLock;
|
||||||
WaitableEvent startSuspensionEvent, defaultEvent;
|
WaitableEvent startSuspensionEvent, defaultEvent;
|
||||||
bool volatile shouldExit;
|
bool volatile shouldExit;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <beast/threads/impl/RecursiveMutex.cpp>
|
|
||||||
#include <beast/threads/impl/Stoppable.cpp>
|
#include <beast/threads/impl/Stoppable.cpp>
|
||||||
#include <beast/threads/impl/Stoppable.test.cpp>
|
#include <beast/threads/impl/Stoppable.test.cpp>
|
||||||
#include <beast/threads/impl/Thread.cpp>
|
#include <beast/threads/impl/Thread.cpp>
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
||||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
||||||
|
|
||||||
Portions of this file are from JUCE.
|
|
||||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
||||||
Please visit http://www.juce.com
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
//==============================================================================
|
|
||||||
|
|
||||||
#include <beast/threads/RecursiveMutex.h>
|
|
||||||
|
|
||||||
#if BEAST_WINDOWS
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
#undef check
|
|
||||||
#undef direct
|
|
||||||
#undef max
|
|
||||||
#undef min
|
|
||||||
#undef TYPE_BOOL
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
RecursiveMutex::RecursiveMutex()
|
|
||||||
{
|
|
||||||
// (just to check the MS haven't changed this structure and broken things...)
|
|
||||||
static_assert (sizeof (CRITICAL_SECTION) <= sizeof (section), "");
|
|
||||||
|
|
||||||
InitializeCriticalSection ((CRITICAL_SECTION*) section);
|
|
||||||
}
|
|
||||||
|
|
||||||
RecursiveMutex::~RecursiveMutex()
|
|
||||||
{
|
|
||||||
DeleteCriticalSection ((CRITICAL_SECTION*) section);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecursiveMutex::lock() const
|
|
||||||
{
|
|
||||||
EnterCriticalSection ((CRITICAL_SECTION*) section);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecursiveMutex::unlock() const
|
|
||||||
{
|
|
||||||
LeaveCriticalSection ((CRITICAL_SECTION*) section);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RecursiveMutex::try_lock() const
|
|
||||||
{
|
|
||||||
return TryEnterCriticalSection ((CRITICAL_SECTION*) section) != FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace beast {
|
|
||||||
|
|
||||||
RecursiveMutex::RecursiveMutex()
|
|
||||||
{
|
|
||||||
pthread_mutexattr_t atts;
|
|
||||||
pthread_mutexattr_init (&atts);
|
|
||||||
pthread_mutexattr_settype (&atts, PTHREAD_MUTEX_RECURSIVE);
|
|
||||||
#if ! BEAST_ANDROID
|
|
||||||
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
|
|
||||||
#endif
|
|
||||||
pthread_mutex_init (&mutex, &atts);
|
|
||||||
pthread_mutexattr_destroy (&atts);
|
|
||||||
}
|
|
||||||
|
|
||||||
RecursiveMutex::~RecursiveMutex()
|
|
||||||
{
|
|
||||||
pthread_mutex_destroy (&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecursiveMutex::lock() const
|
|
||||||
{
|
|
||||||
pthread_mutex_lock (&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecursiveMutex::unlock() const
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock (&mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RecursiveMutex::try_lock() const
|
|
||||||
{
|
|
||||||
return pthread_mutex_trylock (&mutex) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -73,7 +73,7 @@ void beast_threadEntryPoint (void* userData)
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
void Thread::startThread()
|
void Thread::startThread()
|
||||||
{
|
{
|
||||||
const RecursiveMutex::ScopedLockType sl (startStopLock);
|
std::lock_guard<std::recursive_mutex> sl (startStopLock);
|
||||||
|
|
||||||
shouldExit = false;
|
shouldExit = false;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ void Thread::waitForThreadToExit () const
|
|||||||
|
|
||||||
void Thread::stopThread ()
|
void Thread::stopThread ()
|
||||||
{
|
{
|
||||||
const RecursiveMutex::ScopedLockType sl (startStopLock);
|
std::lock_guard<std::recursive_mutex> sl (startStopLock);
|
||||||
|
|
||||||
if (isThreadRunning())
|
if (isThreadRunning())
|
||||||
{
|
{
|
||||||
@@ -115,7 +115,7 @@ void Thread::stopThread ()
|
|||||||
|
|
||||||
void Thread::stopThreadAsync ()
|
void Thread::stopThreadAsync ()
|
||||||
{
|
{
|
||||||
const RecursiveMutex::ScopedLockType sl (startStopLock);
|
std::lock_guard<std::recursive_mutex> sl (startStopLock);
|
||||||
|
|
||||||
if (isThreadRunning())
|
if (isThreadRunning())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,12 +29,6 @@ namespace beast {
|
|||||||
namespace Debug
|
namespace Debug
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Break to debugger if a debugger is attached to a debug build.
|
|
||||||
|
|
||||||
Does nothing if no debugger is attached, or the build is not a debug build.
|
|
||||||
*/
|
|
||||||
extern void breakPoint ();
|
|
||||||
|
|
||||||
/** Given a file and line number this formats a suitable string.
|
/** Given a file and line number this formats a suitable string.
|
||||||
Usually you will pass __FILE__ and __LINE__ here.
|
Usually you will pass __FILE__ and __LINE__ here.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,18 +25,6 @@ namespace beast {
|
|||||||
|
|
||||||
namespace Debug {
|
namespace Debug {
|
||||||
|
|
||||||
void breakPoint ()
|
|
||||||
{
|
|
||||||
#if BEAST_DEBUG
|
|
||||||
if (beast_isRunningUnderDebugger ())
|
|
||||||
beast_breakDebugger;
|
|
||||||
|
|
||||||
#else
|
|
||||||
bassertfalse;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if BEAST_MSVC && defined (_DEBUG)
|
#if BEAST_MSVC && defined (_DEBUG)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
#include <beast/module/core/text/LexicalCast.h>
|
#include <beast/module/core/text/LexicalCast.h>
|
||||||
#include <beast/module/core/thread/DeadlineTimer.h>
|
#include <beast/module/core/thread/DeadlineTimer.h>
|
||||||
#include <beast/module/core/system/SystemStats.h>
|
#include <beast/module/core/system/SystemStats.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/utility/make_lock.h>
|
#include <beast/utility/make_lock.h>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED
|
#ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED
|
||||||
#define RIPPLE_BASICS_RANDOM_H_INCLUDED
|
#define RIPPLE_BASICS_RANDOM_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/is_call_possible.h>
|
#include <beast/is_call_possible.h>
|
||||||
#include <beast/win32_workaround.h>
|
#include <beast/win32_workaround.h>
|
||||||
#include <boost/thread/tss.hpp>
|
#include <boost/thread/tss.hpp>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <ripple/crypto/impl/ec_key.h>
|
#include <ripple/crypto/impl/ec_key.h>
|
||||||
#include <ripple/crypto/impl/ECDSAKey.h>
|
#include <ripple/crypto/impl/ECDSAKey.h>
|
||||||
#include <ripple/crypto/csprng.h>
|
#include <ripple/crypto/csprng.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <openssl/ec.h>
|
#include <openssl/ec.h>
|
||||||
#include <openssl/ecdsa.h>
|
#include <openssl/ecdsa.h>
|
||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
#include <ripple/basics/random.h>
|
#include <ripple/basics/random.h>
|
||||||
#include <ripple/basics/StringUtilities.h>
|
#include <ripple/basics/StringUtilities.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <ripple/basics/BasicConfig.h>
|
#include <ripple/basics/BasicConfig.h>
|
||||||
#include <ripple/unity/rocksdb.h>
|
#include <ripple/unity/rocksdb.h>
|
||||||
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
#include <beast/module/core/diagnostic/UnitTestUtilities.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <beast/unit_test/thread.h>
|
#include <beast/unit_test/thread.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#include <ripple/protocol/Serializer.h>
|
#include <ripple/protocol/Serializer.h>
|
||||||
#include <ripple/protocol/RipplePublicKey.h>
|
#include <ripple/protocol/RipplePublicKey.h>
|
||||||
#include <ripple/protocol/types.h>
|
#include <ripple/protocol/types.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <ed25519-donna/ed25519.h>
|
#include <ed25519-donna/ed25519.h>
|
||||||
#include <openssl/ripemd.h>
|
#include <openssl/ripemd.h>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include <ripple/crypto/GenerateDeterministicKey.h>
|
#include <ripple/crypto/GenerateDeterministicKey.h>
|
||||||
#include <ripple/crypto/csprng.h>
|
#include <ripple/crypto/csprng.h>
|
||||||
#include <beast/crypto/secure_erase.h>
|
#include <beast/crypto/secure_erase.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <ed25519-donna/ed25519.h>
|
#include <ed25519-donna/ed25519.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
#include <BeastConfig.h>
|
#include <BeastConfig.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
#include <beast/chrono/chrono_io.h>
|
#include <beast/chrono/chrono_io.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
#include <ripple/protocol/JsonFields.h>
|
#include <ripple/protocol/JsonFields.h>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <beast/random/rngfill.h>
|
#include <beast/rngfill.h>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <ripple/basics/StringUtilities.h>
|
#include <ripple/basics/StringUtilities.h>
|
||||||
#include <ripple/basics/UnorderedContainers.h>
|
#include <ripple/basics/UnorderedContainers.h>
|
||||||
#include <ripple/protocol/UInt160.h>
|
#include <ripple/protocol/UInt160.h>
|
||||||
#include <beast/random/xor_shift_engine.h>
|
#include <beast/xor_shift_engine.h>
|
||||||
#include <beast/unit_test/suite.h>
|
#include <beast/unit_test/suite.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|||||||
Reference in New Issue
Block a user