Cleanup unused Beast bits and pieces:

This cleanup does not remove Boost.Beast code, but old-style Beast
which is no longer relevant or helpful.
This commit is contained in:
Nik Bougalis
2018-09-11 19:07:33 -07:00
parent 58f786cbb4
commit 1682fe3a39
19 changed files with 3 additions and 746 deletions

View File

@@ -171,19 +171,12 @@ endif ()
option (beast_no_unit_test_inline
"Prevents unit test definitions from being inserted into global table"
OFF)
option (beast_force_debug
"Force BEAST_DEBUG regardless of DEBUG settings"
OFF)
# NOTE - THIS OPTION CURRENTLY DOES NOT COMPILE :
# TODO: fix or remove
option (verify_nodeobject_keys
"This verifies that the hash of node objects matches the payload. \
This check is expensive - use with caution."
OFF)
option (dump_leaks_on_exit
"Displays heap blocks and counted objects which were not disposed of\
during exit. Only implemented for windows builds."
ON)
option (single_io_service_thread
"Restricts the number of threads calling io_service::run to one. \
This can be useful when debugging."
@@ -192,10 +185,6 @@ option (boost_show_deprecated
"Allow boost to fail on deprecated usage. Only useful if you're trying\
to find deprecated calls."
OFF)
# beast_check_mem_leaks can't be an option() because we want to support an
# "undefined" which means use default behavior
# option (beast_check_mem_leaks
# "Force beast mem leak checking. Default is on for DEBUG builds. Only implemented on WIN32"
if (WIN32)
option (beast_disable_autolink "Disables autolinking of system libraries on WIN32" OFF)
else ()
@@ -386,10 +375,7 @@ target_compile_definitions (opts
BOOST_BEAST_ALLOW_DEPRECATED
BOOST_FILESYSTEM_DEPRECATED
>
BEAST_CHECK_MEMORY_LEAKS=$<BOOL:${beast_check_mem_leaks}>
RIPPLE_DUMP_LEAKS_ON_EXIT=$<BOOL:${dump_leaks_on_exit}>
$<$<BOOL:${beast_no_unit_test_inline}>:BEAST_NO_UNIT_TEST_INLINE=1>
$<$<BOOL:${beast_force_debug}>:BEAST_FORCE_DEBUG=1>
$<$<BOOL:${beast_disable_autolink}>:BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES=1>
$<$<BOOL:${single_io_service_thread}>:RIPPLE_SINGLE_IO_SERVICE_THREAD=1>
# doesn't currently compile ? :
@@ -1327,7 +1313,6 @@ else ()
src/ripple/beast/net/impl/IPAddressV4.cpp
src/ripple/beast/net/impl/IPAddressV6.cpp
src/ripple/beast/net/impl/IPEndpoint.cpp
src/ripple/beast/utility/src/beast_Debug.cpp
src/ripple/beast/utility/src/beast_Journal.cpp
src/ripple/beast/utility/src/beast_PropertyStream.cpp)
endif ()
@@ -1558,7 +1543,6 @@ install (
DESTINATION include/ripple/beast/clock)
install (
FILES
src/ripple/beast/core/CompilerConfig.h
src/ripple/beast/core/Config.h
src/ripple/beast/core/ConfigCheck.h
src/ripple/beast/core/LexicalCast.h
@@ -2081,7 +2065,6 @@ else ()
src/test/beast/beast_asio_error_test.cpp
src/test/beast/beast_basic_seconds_clock_test.cpp
src/test/beast/beast_io_latency_probe_test.cpp
src/test/beast/beast_weak_fn_test.cpp
src/test/beast/define_print.cpp
#[===============================[
nounity, test sources:

View File

@@ -37,7 +37,6 @@
#include <ripple/protocol/BuildInfo.h>
#include <ripple/beast/clock/basic_seconds_clock.h>
#include <ripple/beast/core/CurrentThreadName.h>
#include <ripple/beast/utility/Debug.h>
#include <beast/unit_test/dstream.hpp>
#include <beast/unit_test/global_suites.hpp>
@@ -766,26 +765,6 @@ int main (int argc, char** argv)
"GCC version 5.1.0 or later is required to compile rippled.");
#endif
//
// These debug heap calls do nothing in release or non Visual Studio builds.
//
// Checks the heap at every allocation and deallocation (slow).
//
//beast::Debug::setAlwaysCheckHeap (false);
// Keeps freed memory blocks and fills them with a guard value.
//
//beast::Debug::setHeapDelayedFree (false);
// At exit, reports all memory blocks which have not been freed.
//
#if RIPPLE_DUMP_LEAKS_ON_EXIT
beast::Debug::setHeapReportLeaks (true);
#else
beast::Debug::setHeapReportLeaks (false);
#endif
atexit(&google::protobuf::ShutdownProtobufLibrary);
std::set_terminate(ripple::terminateHandler);

View File

@@ -1,143 +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_CONFIG_COMPILERCONFIG_H_INCLUDED
#define BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
#include <assert.h>
#include <ripple/beast/core/PlatformConfig.h>
// This file defines miscellaneous macros for debugging, assertions, etc.
#if BEAST_FORCE_DEBUG
# undef BEAST_DEBUG
# define BEAST_DEBUG 1
#endif
/** This macro defines the C calling convention used as the standard for Beast calls.
*/
#if BEAST_MSVC
# define BEAST_CDECL __cdecl
#else
# define BEAST_CDECL
#endif
//------------------------------------------------------------------------------
#if ! DOXYGEN
#define BEAST_JOIN_MACRO_HELPER(a, b) a ## b
#define BEAST_STRINGIFY_MACRO_HELPER(a) #a
#endif
/** A good old-fashioned C macro concatenation helper.
This combines two items (which may themselves be macros) into a single string,
avoiding the pitfalls of the ## macro operator.
*/
#define BEAST_JOIN_MACRO(item1, item2) BEAST_JOIN_MACRO_HELPER (item1, item2)
/** A handy C macro for stringifying any symbol, rather than just a macro parameter.
*/
#define BEAST_STRINGIFY(item) BEAST_STRINGIFY_MACRO_HELPER (item)
//------------------------------------------------------------------------------
#if BEAST_MSVC || DOXYGEN
/** This can be placed before a stack or member variable declaration to tell
the compiler to align it to the specified number of bytes.
*/
#define BEAST_ALIGN(bytes) __declspec (align (bytes))
#else
#define BEAST_ALIGN(bytes) __attribute__ ((aligned (bytes)))
#endif
//------------------------------------------------------------------------------
// Cross-compiler deprecation macros..
#ifdef DOXYGEN
/** This macro can be used to wrap a function which has been deprecated. */
#define BEAST_DEPRECATED(functionDef)
#elif BEAST_MSVC && ! BEAST_NO_DEPRECATION_WARNINGS
#define BEAST_DEPRECATED(functionDef) __declspec(deprecated) functionDef
#elif BEAST_GCC && ! BEAST_NO_DEPRECATION_WARNINGS
#define BEAST_DEPRECATED(functionDef) functionDef __attribute__ ((deprecated))
#else
#define BEAST_DEPRECATED(functionDef) functionDef
#endif
//------------------------------------------------------------------------------
#if BEAST_GCC
# define BEAST_PACKED __attribute__((packed))
#elif ! DOXYGEN
# define BEAST_PACKED
#endif
//------------------------------------------------------------------------------
// Here, we'll check for C++11 compiler support, and if it's not available, define
// a few workarounds, so that we can still use some of the newer language features.
#if defined (__GXX_EXPERIMENTAL_CXX0X__) && defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
# define BEAST_COMPILER_SUPPORTS_NOEXCEPT 1
# define BEAST_COMPILER_SUPPORTS_NULLPTR 1
# define BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (BEAST_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL)
# define BEAST_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
# endif
#endif
#if BEAST_CLANG && defined (__has_feature)
# if __has_feature (cxx_nullptr)
# define BEAST_COMPILER_SUPPORTS_NULLPTR 1
# endif
# if __has_feature (cxx_noexcept)
# define BEAST_COMPILER_SUPPORTS_NOEXCEPT 1
# endif
# if __has_feature (cxx_rvalue_references)
# define BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
# endif
# ifndef BEAST_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL
# define BEAST_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
# endif
# ifndef BEAST_COMPILER_SUPPORTS_ARC
# define BEAST_COMPILER_SUPPORTS_ARC 1
# endif
#endif
#if defined (_MSC_VER) && _MSC_VER >= 1600
# define BEAST_COMPILER_SUPPORTS_NULLPTR 1
# define BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
#endif
#if defined (_MSC_VER) && _MSC_VER >= 1700
# define BEAST_COMPILER_SUPPORTS_OVERRIDE_AND_FINAL 1
#endif
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
# define BEAST_MOVE_ARG(type) type&&
# define BEAST_MOVE_CAST(type) static_cast<type&&>
#else
# define BEAST_MOVE_ARG(type) type
# define BEAST_MOVE_CAST(type) type
#endif
#endif

View File

@@ -25,7 +25,6 @@
#define BEAST_CONFIG_H_INCLUDED
#include <ripple/beast/core/PlatformConfig.h>
#include <ripple/beast/core/CompilerConfig.h>
#include <ripple/beast/core/StandardConfig.h>
#include <ripple/beast/core/ConfigCheck.h>

View File

@@ -24,28 +24,6 @@
// Apply sensible defaults for the configuration settings
//
#ifndef BEAST_FORCE_DEBUG
#define BEAST_FORCE_DEBUG 0
#endif
#ifndef BEAST_LOG_ASSERTIONS
# if BEAST_ANDROID
# define BEAST_LOG_ASSERTIONS 1
# else
# define BEAST_LOG_ASSERTIONS 0
# endif
#endif
#if BEAST_DEBUG && ! defined (BEAST_CHECK_MEMORY_LEAKS)
#define BEAST_CHECK_MEMORY_LEAKS 1
#endif
#ifndef BEAST_DISABLE_CONTRACT_CHECKS
#define BEAST_DISABLE_CONTRACT_CHECKS 0
#endif
//------------------------------------------------------------------------------
#ifndef BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES
#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES 0
#endif

View File

@@ -22,6 +22,7 @@
#include <ripple/beast/core/Config.h>
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <iostream>

View File

@@ -24,10 +24,6 @@
#ifndef BEAST_CONFIG_STANDARDCONFIG_H_INCLUDED
#define BEAST_CONFIG_STANDARDCONFIG_H_INCLUDED
#ifndef BEAST_CONFIG_COMPILERCONFIG_H_INCLUDED
#error "CompilerConfig.h must be included first"
#endif
// Now we'll include some common OS headers..
#if BEAST_MSVC
#pragma warning (push)

View File

@@ -17,6 +17,5 @@
*/
//==============================================================================
#include <ripple/beast/utility/src/beast_Debug.cpp>
#include <ripple/beast/utility/src/beast_Journal.cpp>
#include <ripple/beast/utility/src/beast_PropertyStream.cpp>

View File

@@ -1,66 +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_UTILITY_DEBUG_H_INCLUDED
#define BEAST_UTILITY_DEBUG_H_INCLUDED
#include <string>
namespace beast {
// Auxiliary outines for debugging
namespace Debug
{
//
// These control the MSVC C Runtime Debug heap.
//
// The calls currently do nothing on other platforms.
//
/** Calls checkHeap() at every allocation and deallocation.
*/
extern void setAlwaysCheckHeap (bool bAlwaysCheck);
/** Keep freed memory blocks in the heap's linked list, assign them the
_FREE_BLOCK type, and fill them with the byte value 0xDD.
*/
extern void setHeapDelayedFree (bool bDelayedFree);
/** Perform automatic leak checking at program exit through a call to
dumpMemoryLeaks() and generate an error report if the application
failed to free all the memory it allocated.
*/
extern void setHeapReportLeaks (bool bReportLeaks);
/** Report all memory blocks which have not been freed.
*/
extern void reportLeaks ();
/** Confirms the integrity of the memory blocks allocated in the
debug heap (debug version only.
*/
extern void checkHeap ();
}
}
#endif

View File

@@ -20,8 +20,6 @@
#ifndef BEAST_UTILITY_ZERO_H_INCLUDED
#define BEAST_UTILITY_ZERO_H_INCLUDED
#include <ripple/beast/core/CompilerConfig.h>
namespace beast {
/** Zero allows classes to offer efficient comparisons to zero.

View File

@@ -1,112 +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.
*/
//==============================================================================
#include <ripple/beast/utility/Debug.h>
namespace beast {
namespace Debug {
//------------------------------------------------------------------------------
#if BEAST_MSVC && defined (_DEBUG)
#if BEAST_CHECK_MEMORY_LEAKS
struct DebugFlagsInitialiser
{
DebugFlagsInitialiser()
{
// Activate leak checks on exit in the MSVC Debug CRT (C Runtime)
//
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
}
};
static DebugFlagsInitialiser debugFlagsInitialiser;
#endif
void setAlwaysCheckHeap (bool bAlwaysCheck)
{
int flags = _CrtSetDbgFlag (_CRTDBG_REPORT_FLAG);
if (bAlwaysCheck) flags |= _CRTDBG_CHECK_ALWAYS_DF; // on
else flags &= ~_CRTDBG_CHECK_ALWAYS_DF; // off
_CrtSetDbgFlag (flags);
}
void setHeapDelayedFree (bool bDelayedFree)
{
int flags = _CrtSetDbgFlag (_CRTDBG_REPORT_FLAG);
if (bDelayedFree) flags |= _CRTDBG_DELAY_FREE_MEM_DF; // on
else flags &= ~_CRTDBG_DELAY_FREE_MEM_DF; // off
_CrtSetDbgFlag (flags);
}
void setHeapReportLeaks (bool bReportLeaks)
{
int flags = _CrtSetDbgFlag (_CRTDBG_REPORT_FLAG);
if (bReportLeaks) flags |= _CRTDBG_LEAK_CHECK_DF; // on
else flags &= ~_CRTDBG_LEAK_CHECK_DF; // off
_CrtSetDbgFlag (flags);
}
void reportLeaks ()
{
_CrtDumpMemoryLeaks ();
}
void checkHeap ()
{
_CrtCheckMemory ();
}
//------------------------------------------------------------------------------
#else
void setAlwaysCheckHeap (bool)
{
}
void setHeapDelayedFree (bool)
{
}
void setHeapReportLeaks (bool)
{
}
void reportLeaks ()
{
}
void checkHeap ()
{
}
#endif
}
}

View File

@@ -1,179 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2014, 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_WEAK_FN_H_INCLUDED
#define BEAST_WEAK_FN_H_INCLUDED
#include <boost/beast/core/detail/empty_base_optimization.hpp>
#include <memory>
// Original version:
// http://lists.boost.org/Archives/boost/att-189469/weak_fn.hpp
//
// This work was adapted from source code with this copyright notice:
//
// weak_fun.hpp
//
// Copyright (c) 2009 Artyom Beilis
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
namespace beast {
// Policy throws if weak pointer is expired
template <class V = void>
struct throw_if_invalid
{
explicit throw_if_invalid() = default;
V operator()() const
{
throw std::bad_weak_ptr();
}
};
// Policy returns a value if weak pointer is expired
template <class V>
struct return_default_if_invalid
{
return_default_if_invalid()
: def_value_()
{ }
return_default_if_invalid(V def_value)
: def_value_(def_value)
{ }
V operator()() const
{
return def_value_;
}
private:
V def_value_;
};
// Policy does nothing if weak pointer is expired
template <class V>
struct ignore_if_invalid
{
explicit ignore_if_invalid() = default;
V operator()() const
{
return V();
}
};
template <class V>
using default_invalid_policy = ignore_if_invalid<V>;
namespace detail {
template <class T, class R, class Policy, class... Args>
class weak_binder
: private boost::beast::detail::empty_base_optimization<Policy>
{
private:
using member_type = R (T::*)(Args...);
using pointer_type = std::weak_ptr<T>;
using shared_type = std::shared_ptr<T>;
member_type member_;
pointer_type object_;
public:
using result_type = R;
weak_binder (member_type member,
Policy policy, pointer_type object)
: boost::beast::detail::empty_base_optimization<Policy>(std::move(policy))
, member_(member)
, object_(object)
{ }
R operator()(Args... args)
{
if(auto p = object_.lock())
return ((*p).*member_)(args...);
return this->member()();
}
};
} // detail
/** Returns a callback that can be used with std::bind and a weak_ptr.
When called, it tries to lock weak_ptr to get a shared_ptr. If successful,
it calls given member function with given arguments. If not successful,
the policy functor is called. Built-in policies are:
ignore_if_invalid does nothing
throw_if_invalid throws `bad_weak_ptr`
return_default_if_invalid returns a chosen value
Example:
struct Foo {
void bar(int i) {
std::cout << i << std::endl;
}
};
struct do_something {
void operator()() {
std::cout << "outdated reference" << std::endl;
}
};
int main()
{
std::shared_ptr<Foo> sp(new Foo());
std::weak_ptr<Foo> wp(sp);
std::bind(weak_fn(&Foo::bar, wp), _1)(1);
sp.reset();
std::bind(weak_fn(&Foo::bar, wp), 1)();
std::bind(weak_fn(&Foo::bar, wp, do_something()), 1)();
}
*/
/** @{ */
template <class T, class R, class Policy, class... Args>
detail::weak_binder<T, R, Policy, Args...>
weak_fn (R (T::*member)(Args...), std::shared_ptr<T> p,
Policy policy)
{
return detail::weak_binder<T, R,
Policy, Args...>(member, policy, p);
}
template <class T, class R, class... Args>
detail::weak_binder<T, R, default_invalid_policy<R>, Args...>
weak_fn (R (T::*member)(Args...), std::shared_ptr<T> p)
{
return detail::weak_binder<T, R,
default_invalid_policy<R>, Args...>(member,
default_invalid_policy<R>{}, p);
}
/** @} */
} // beast
#endif

View File

@@ -22,7 +22,6 @@
#include <ripple/peerfinder/Slot.h>
#include <ripple/peerfinder/PeerfinderManager.h>
#include <ripple/beast/core/CompilerConfig.h>
#include <ripple/beast/container/aged_unordered_map.h>
#include <ripple/beast/container/aged_container_utility.h>
#include <boost/optional.hpp>

View File

@@ -22,7 +22,6 @@
#include <ripple/basics/contract.h>
#include <ripple/core/SociDB.h>
#include <ripple/beast/utility/Debug.h>
#include <boost/optional.hpp>
namespace ripple {

View File

@@ -135,11 +135,6 @@ public:
make(Slice const& rawNode, std::uint32_t seq, SHANodeFormat format,
SHAMapHash const& hash, bool hashValid, beast::Journal j,
SHAMapNodeID const& id = SHAMapNodeID{});
// debugging
#ifdef BEAST_DEBUG
static void dump (SHAMapNodeID const&, beast::Journal journal);
#endif
};
class SHAMapInnerNodeV2;

View File

@@ -600,17 +600,6 @@ int SHAMapInnerNode::getBranchCount () const
return count;
}
#ifdef BEAST_DEBUG
void
SHAMapAbstractNode::dump(const SHAMapNodeID & id, beast::Journal journal)
{
JLOG(journal.debug()) <<
"SHAMapTreeNode(" << id.getNodeID () << ")";
}
#endif // BEAST_DEBUG
std::string
SHAMapAbstractNode::getString(const SHAMapNodeID & id) const
{

View File

@@ -17,7 +17,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/beast/unit_test.h>
#include <ripple/beast/utility/Debug.h>
namespace beast {
// A simple unit test to determine the diagnostic settings in a build.
@@ -43,21 +43,11 @@ public:
#endif
}
static int beastForceDebug()
{
#ifdef BEAST_FORCE_DEBUG
return BEAST_FORCE_DEBUG;
#else
return 0;
#endif
}
void run() override
{
log <<
"_DEBUG = " << envDebug() << '\n' <<
"BEAST_DEBUG = " << beastDebug() << '\n' <<
"BEAST_FORCE_DEBUG = " << beastForceDebug() << '\n' <<
"sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl;
pass();
}

View File

@@ -1,147 +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.
*/
//==============================================================================
#include <ripple/beast/utility/weak_fn.h>
#include <ripple/beast/unit_test.h>
namespace beast {
class weak_fn_test : public beast::unit_test::suite
{
public:
struct T
{
bool& called_;
explicit
T (bool& called)
: called_(called)
{
}
void
fv()
{
called_ = true;
}
void
fi(int i)
{
called_ = true;
}
void
fis(int, std::string)
{
called_ = true;
}
int
fri()
{
called_ = true;
return 2;
}
};
void
run() override
{
{
bool called = false;
auto const p = std::make_shared<T>(called);
std::bind(weak_fn(&T::fv, p))();
BEAST_EXPECT(called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
auto call = std::bind(weak_fn(&T::fv, p));
p.reset();
call();
BEAST_EXPECT(! called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
std::bind(weak_fn(&T::fi, p), 1)();
BEAST_EXPECT(called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
std::bind(weak_fn(&T::fi, p),
std::placeholders::_1)(1);
BEAST_EXPECT(called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
std::bind(weak_fn(&T::fis, p),
1, std::placeholders::_1)("foo");
BEAST_EXPECT(called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
try
{
auto call = std::bind(weak_fn(&T::fis, p, throw_if_invalid<>()),
1, std::placeholders::_1);
p.reset();
call("foo");
fail();
}
catch(std::bad_weak_ptr const&)
{
BEAST_EXPECT(! called);
}
}
{
bool called = false;
auto p = std::make_shared<T>(called);
BEAST_EXPECT(std::bind(weak_fn(&T::fri, p))() == 2);
BEAST_EXPECT(called);
}
{
bool called = false;
auto p = std::make_shared<T>(called);
auto call = std::bind(weak_fn(&T::fv, p,
[&called]()
{
called = true;
}));
p.reset();
call();
BEAST_EXPECT(called);
}
}
};
BEAST_DEFINE_TESTSUITE(weak_fn,asio,beast);
}

View File

@@ -18,7 +18,6 @@
*/
//==============================================================================
#include <test/beast/beast_weak_fn_test.cpp>
#include <test/beast/beast_Zero_test.cpp>
#include <test/beast/define_print.cpp>
#include <test/beast/IPEndpoint_test.cpp>