updated boost on windows
This commit is contained in:
@@ -38,8 +38,8 @@
|
||||
#if defined(BOOST_LOG_ADAPTIVE_MUTEX_USE_WINAPI)
|
||||
|
||||
#include <boost/log/detail/pause.hpp>
|
||||
#include <boost/winapi/thread.hpp>
|
||||
#include <boost/detail/interlocked.hpp>
|
||||
#include <boost/detail/winapi/thread.hpp>
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
|
||||
# if defined(__INTEL_COMPILER)
|
||||
@@ -103,10 +103,10 @@ public:
|
||||
{
|
||||
// Restart spinning after waking up this thread
|
||||
pause_count = initial_pause;
|
||||
SwitchToThread();
|
||||
boost::winapi::SwitchToThread();
|
||||
}
|
||||
#else
|
||||
SwitchToThread();
|
||||
boost::winapi::SwitchToThread();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
77
winx64/include/boost/log/detail/allocator_traits.hpp
Normal file
77
winx64/include/boost/log/detail/allocator_traits.hpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2018.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file allocator_traits.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 03.01.2018
|
||||
*
|
||||
* \brief This header is the Boost.Log library implementation, see the library documentation
|
||||
* at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
|
||||
#define BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
|
||||
|
||||
#include <memory>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/container/allocator_traits.hpp>
|
||||
#endif
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
BOOST_LOG_OPEN_NAMESPACE
|
||||
|
||||
namespace aux {
|
||||
|
||||
// A portable name for allocator traits
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
using std::allocator_traits;
|
||||
#else
|
||||
using boost::container::allocator_traits;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief A standalone trait to rebind an allocator to another type.
|
||||
*
|
||||
* The important difference from <tt>std::allocator_traits<Alloc>::rebind_alloc<U></tt> is that this
|
||||
* trait does not require template aliases and thus is compatible with C++03. There is
|
||||
* <tt>boost::container::allocator_traits<Alloc>::portable_rebind_alloc<U></tt>, but it is not present in <tt>std::allocator_traits</tt>.
|
||||
* It will also attempt to instantiate the allocator type to test if it provides the nested <tt>rebind</tt> template. We don't want
|
||||
* that to happen because it prohibits using <tt>std::allocator<void></tt> in C++17 and later, which deprecated
|
||||
* this allocator specialization. This standalone trait does not use the nested <tt>rebind</tt> template in this case.
|
||||
*/
|
||||
template< typename Allocator, typename U >
|
||||
struct rebind_alloc
|
||||
{
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef typename std::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE rebind_alloc< U > type;
|
||||
#else
|
||||
typedef typename boost::container::allocator_traits< Allocator >::BOOST_NESTED_TEMPLATE portable_rebind_alloc< U >::type type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template< typename U >
|
||||
struct rebind_alloc< std::allocator< void >, U >
|
||||
{
|
||||
typedef std::allocator< U > type;
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/log/detail/footer.hpp>
|
||||
|
||||
#endif // BOOST_LOG_ALLOCATOR_TRAITS_HPP_INCLUDED_
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <string>
|
||||
#include <streambuf>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/locale/utf.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
@@ -277,11 +277,13 @@ protected:
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
size_type length_until_boundary(const char_type* s, size_type n, size_type max_size) const
|
||||
{
|
||||
return length_until_boundary(s, n, max_size, mpl::bool_< sizeof(char_type) == 1u >());;
|
||||
BOOST_ASSERT(max_size <= n);
|
||||
return length_until_boundary(s, n, max_size, boost::integral_constant< bool, sizeof(char_type) == 1u >());
|
||||
}
|
||||
|
||||
private:
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, mpl::true_) const
|
||||
size_type length_until_boundary(const char_type* s, size_type, size_type max_size, boost::true_type) const
|
||||
{
|
||||
std::locale loc = this->getloc();
|
||||
std::codecvt< wchar_t, char, std::mbstate_t > const& fac = std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc);
|
||||
@@ -290,12 +292,12 @@ protected:
|
||||
}
|
||||
|
||||
//! Finds the string length so that it includes only complete characters, and does not exceed \a max_size
|
||||
static size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, mpl::false_)
|
||||
static size_type length_until_boundary(const char_type* s, size_type n, size_type max_size, boost::false_type)
|
||||
{
|
||||
// Note: Although it's not required to be true for wchar_t, here we assume that the string has Unicode encoding.
|
||||
// Compilers use some version of Unicode for wchar_t on all tested platforms, and std::locale doesn't offer a way
|
||||
// to find the character boundary for character types other than char anyway.
|
||||
typedef boost::locale::utf::utf_traits< CharT > utf_traits;
|
||||
typedef boost::locale::utf::utf_traits< char_type > utf_traits;
|
||||
|
||||
size_type pos = max_size;
|
||||
while (pos > 0u)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
// Try including WinAPI config as soon as possible so that any other headers don't include Windows SDK headers
|
||||
#if defined(BOOST_OS_WINDOWS_AVAILABLE)
|
||||
#include <boost/detail/winapi/config.hpp>
|
||||
#include <boost/winapi/config.hpp>
|
||||
#endif
|
||||
|
||||
#include <limits.h> // To bring in libc macros
|
||||
@@ -116,6 +116,19 @@
|
||||
# define BOOST_LOG_NO_ASIO
|
||||
#endif
|
||||
|
||||
#if defined(__VXWORKS__)
|
||||
# define BOOST_LOG_NO_GETPGRP
|
||||
# define BOOST_LOG_NO_GETSID
|
||||
// for _WRS_CONFIG_USER_MANAGEMENT used below
|
||||
# include <vsbConfig.h>
|
||||
#endif
|
||||
|
||||
#if (!defined(__CRYSTAX__) && defined(__ANDROID__) && (__ANDROID_API__+0) < 21) \
|
||||
|| (defined(__VXWORKS__) && !defined(_WRS_CONFIG_USER_MANAGEMENT))
|
||||
// Until Android API version 21 Google NDK does not provide getpwuid_r
|
||||
# define BOOST_LOG_NO_GETPWUID_R
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_LOG_USE_NATIVE_SYSLOG) && defined(BOOST_LOG_NO_ASIO)
|
||||
# ifndef BOOST_LOG_WITHOUT_SYSLOG
|
||||
# define BOOST_LOG_WITHOUT_SYSLOG
|
||||
@@ -144,10 +157,13 @@
|
||||
#define BOOST_LOG_NO_CXX11_DEFAULTED_NOEXCEPT_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || (defined(BOOST_CLANG) && (((__clang_major__+0) == 3) && ((__clang_minor__+0) <= 1)))
|
||||
// Clang 3.1 cannot handle a defaulted constexpr constructor in some cases (presumably, if the class contains a member with a constexpr constructor)
|
||||
#define BOOST_LOG_NO_CXX11_DEFAULTED_CONSTEXPR_CONSTRUCTORS
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define BOOST_LOG_NO_VTABLE __declspec(novtable)
|
||||
#elif defined(__GNUC__)
|
||||
# define BOOST_LOG_NO_VTABLE
|
||||
#else
|
||||
# define BOOST_LOG_NO_VTABLE
|
||||
#endif
|
||||
@@ -199,18 +215,14 @@
|
||||
# define BOOST_LOG_NORETURN
|
||||
#endif
|
||||
|
||||
// GCC and compatible compilers may require marking types that may alias other types
|
||||
#if defined(__GNUC__)
|
||||
# define BOOST_LOG_MAY_ALIAS __attribute__ ((__may_alias__))
|
||||
#else
|
||||
# define BOOST_LOG_MAY_ALIAS
|
||||
#endif
|
||||
// Some compilers may require marking types that may alias other types
|
||||
#define BOOST_LOG_MAY_ALIAS BOOST_MAY_ALIAS
|
||||
|
||||
#if !defined(BOOST_LOG_BUILDING_THE_LIB)
|
||||
|
||||
// Detect if we're dealing with dll
|
||||
# if defined(BOOST_LOG_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
|
||||
# define BOOST_LOG_DLL
|
||||
# define BOOST_LOG_DLL
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_LOG_DLL)
|
||||
@@ -296,8 +308,14 @@
|
||||
|
||||
#ifndef BOOST_LOG_CPU_CACHE_LINE_SIZE
|
||||
//! The macro defines the CPU cache line size for the target architecture. This is mostly used for optimization.
|
||||
#if defined(__s390__) || defined(__s390x__)
|
||||
#define BOOST_LOG_CPU_CACHE_LINE_SIZE 256
|
||||
#elif defined(powerpc) || defined(__powerpc__) || defined(__ppc__)
|
||||
#define BOOST_LOG_CPU_CACHE_LINE_SIZE 128
|
||||
#else
|
||||
#define BOOST_LOG_CPU_CACHE_LINE_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -343,11 +361,18 @@ namespace log {
|
||||
# if !defined(BOOST_NO_CXX11_INLINE_NAMESPACES)
|
||||
|
||||
inline namespace BOOST_LOG_VERSION_NAMESPACE {}
|
||||
}
|
||||
|
||||
# define BOOST_LOG_OPEN_NAMESPACE namespace log { inline namespace BOOST_LOG_VERSION_NAMESPACE {
|
||||
# define BOOST_LOG_CLOSE_NAMESPACE }}
|
||||
|
||||
# elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40400
|
||||
|
||||
// GCC 7 deprecated strong using directives but allows inline namespaces in C++03 mode since GCC 4.4.
|
||||
__extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {}
|
||||
|
||||
# define BOOST_LOG_OPEN_NAMESPACE namespace log { __extension__ inline namespace BOOST_LOG_VERSION_NAMESPACE {
|
||||
# define BOOST_LOG_CLOSE_NAMESPACE }}
|
||||
|
||||
# else
|
||||
|
||||
namespace BOOST_LOG_VERSION_NAMESPACE {}
|
||||
@@ -358,12 +383,12 @@ __attribute__((__strong__))
|
||||
# endif
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
# define BOOST_LOG_OPEN_NAMESPACE namespace log { namespace BOOST_LOG_VERSION_NAMESPACE {
|
||||
# define BOOST_LOG_CLOSE_NAMESPACE }}
|
||||
# endif
|
||||
|
||||
} // namespace log
|
||||
|
||||
#else // !defined(BOOST_LOG_DOXYGEN_PASS)
|
||||
|
||||
namespace log {}
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
#ifndef BOOST_LOG_DETAIL_FORMAT_HPP_INCLUDED_
|
||||
#define BOOST_LOG_DETAIL_FORMAT_HPP_INCLUDED_
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/core/uncaught_exceptions.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/log/detail/unhandled_exception_count.hpp>
|
||||
#include <boost/log/detail/cleanup_scope_guard.hpp>
|
||||
#include <boost/log/utility/formatting_ostream.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
@@ -276,7 +277,7 @@ private:
|
||||
|
||||
public:
|
||||
//! Initializing constructor
|
||||
pump(basic_format& owner, stream_type& strm) BOOST_NOEXCEPT : m_owner(&owner), m_stream(&strm), m_exception_count(unhandled_exception_count())
|
||||
pump(basic_format& owner, stream_type& strm) BOOST_NOEXCEPT : m_owner(&owner), m_stream(&strm), m_exception_count(boost::core::uncaught_exceptions())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ public:
|
||||
boost::log::aux::cleanup_guard< basic_format< char_type > > cleanup1(*m_owner);
|
||||
|
||||
BOOST_ASSERT(m_stream != NULL);
|
||||
if (m_exception_count >= unhandled_exception_count())
|
||||
if (m_exception_count >= boost::core::uncaught_exceptions())
|
||||
{
|
||||
// Compose the final string in the stream buffer
|
||||
m_stream->flush();
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <cstddef>
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/utility/explicit_operator_bool.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/preprocessor/iteration/iterate.hpp>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#if defined(BOOST_LOG_LWRWMUTEX_USE_SRWLOCK)
|
||||
|
||||
#include <boost/detail/winapi/srw_lock.hpp>
|
||||
#include <boost/winapi/srw_lock.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -47,28 +47,28 @@ namespace aux {
|
||||
//! A light read/write mutex that uses WinNT 6 and later APIs
|
||||
class light_rw_mutex
|
||||
{
|
||||
boost::detail::winapi::SRWLOCK_ m_Mutex;
|
||||
boost::winapi::SRWLOCK_ m_Mutex;
|
||||
|
||||
public:
|
||||
light_rw_mutex()
|
||||
{
|
||||
boost::detail::winapi::InitializeSRWLock(&m_Mutex);
|
||||
boost::winapi::InitializeSRWLock(&m_Mutex);
|
||||
}
|
||||
void lock_shared()
|
||||
{
|
||||
boost::detail::winapi::AcquireSRWLockShared(&m_Mutex);
|
||||
boost::winapi::AcquireSRWLockShared(&m_Mutex);
|
||||
}
|
||||
void unlock_shared()
|
||||
{
|
||||
boost::detail::winapi::ReleaseSRWLockShared(&m_Mutex);
|
||||
boost::winapi::ReleaseSRWLockShared(&m_Mutex);
|
||||
}
|
||||
void lock()
|
||||
{
|
||||
boost::detail::winapi::AcquireSRWLockExclusive(&m_Mutex);
|
||||
boost::winapi::AcquireSRWLockExclusive(&m_Mutex);
|
||||
}
|
||||
void unlock()
|
||||
{
|
||||
boost::detail::winapi::ReleaseSRWLockExclusive(&m_Mutex);
|
||||
boost::winapi::ReleaseSRWLockExclusive(&m_Mutex);
|
||||
}
|
||||
|
||||
// Noncopyable
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include <boost/move/core.hpp>
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#include <boost/thread/lock_options.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#include <boost/utility/explicit_operator_bool.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
#ifndef BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
|
||||
#define BOOST_LOG_DETAIL_PARAMETER_TOOLS_HPP_INCLUDED_
|
||||
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
#include <boost/preprocessor/control/if.hpp>
|
||||
#include <boost/preprocessor/comparison/equal.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
@@ -121,26 +124,20 @@ struct make_arg_list< ArgT0, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(BOOST_LOG_MAX_PAR
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
|
||||
template< typename T, typename R >
|
||||
struct enable_if_named_parameters {};
|
||||
using enable_if_named_parameters = boost::enable_if_c< boost::mpl::or_< boost::is_base_of< boost::parameter::aux::tagged_argument_base, T >, boost::is_base_of< empty_arg_list, T > >::value, R >;
|
||||
|
||||
template< typename R >
|
||||
struct enable_if_named_parameters< empty_arg_list, R >
|
||||
#else // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
|
||||
template< typename T, typename R >
|
||||
struct enable_if_named_parameters :
|
||||
public boost::enable_if_c< boost::mpl::or_< boost::is_base_of< boost::parameter::aux::tagged_argument_base, T >, boost::is_base_of< empty_arg_list, T > >::value, R >
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template< typename Keyword, typename Arg, typename R >
|
||||
struct enable_if_named_parameters< boost::parameter::aux::tagged_argument< Keyword, Arg >, R >
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
|
||||
template< typename TaggedArg, typename Next, typename R >
|
||||
struct enable_if_named_parameters< boost::parameter::aux::arg_list< TaggedArg, Next >, R >
|
||||
{
|
||||
typedef R type;
|
||||
};
|
||||
#endif // !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
||||
|
||||
} // namespace aux
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
#include <boost/log/detail/allocator_traits.hpp>
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -69,23 +70,22 @@ struct threadsafe_queue_impl
|
||||
virtual bool try_pop(node_base*& node_to_free, node_base*& node_with_value) = 0;
|
||||
};
|
||||
|
||||
//! A helper class to compose some of the types used by the queue
|
||||
template< typename T, typename AllocatorT >
|
||||
struct threadsafe_queue_types
|
||||
//! Thread-safe queue node type
|
||||
template< typename T >
|
||||
struct threadsafe_queue_node :
|
||||
public threadsafe_queue_impl::node_base
|
||||
{
|
||||
struct node :
|
||||
public threadsafe_queue_impl::node_base
|
||||
{
|
||||
typedef typename aligned_storage< sizeof(T), alignment_of< T >::value >::type storage_type;
|
||||
storage_type storage;
|
||||
typedef typename aligned_storage< sizeof(T), alignment_of< T >::value >::type storage_type;
|
||||
storage_type storage;
|
||||
|
||||
node() {}
|
||||
explicit node(T const& val) { new (storage.address()) T(val); }
|
||||
T& value() { return *static_cast< T* >(storage.address()); }
|
||||
void destroy() { static_cast< T* >(storage.address())->~T(); }
|
||||
};
|
||||
BOOST_DEFAULTED_FUNCTION(threadsafe_queue_node(), {})
|
||||
explicit threadsafe_queue_node(T const& val) { new (storage.address()) T(val); }
|
||||
T& value() BOOST_NOEXCEPT { return *static_cast< T* >(storage.address()); }
|
||||
void destroy() BOOST_NOEXCEPT { static_cast< T* >(storage.address())->~T(); }
|
||||
|
||||
typedef typename AllocatorT::BOOST_NESTED_TEMPLATE rebind< node >::other allocator_type;
|
||||
// Copying and assignment is prohibited
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue_node(threadsafe_queue_node const&))
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue_node& operator= (threadsafe_queue_node const&))
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -108,36 +108,13 @@ struct threadsafe_queue_types
|
||||
*/
|
||||
template< typename T, typename AllocatorT = std::allocator< void > >
|
||||
class threadsafe_queue :
|
||||
private threadsafe_queue_types< T, AllocatorT >::allocator_type
|
||||
private boost::log::aux::rebind_alloc< AllocatorT, threadsafe_queue_node< T > >::type
|
||||
{
|
||||
private:
|
||||
typedef typename threadsafe_queue_types< T, AllocatorT >::allocator_type base_type;
|
||||
typedef typename threadsafe_queue_types< T, AllocatorT >::node node;
|
||||
|
||||
//! A simple scope guard to automate memory reclaiming
|
||||
struct auto_deallocate;
|
||||
friend struct auto_deallocate;
|
||||
struct auto_deallocate
|
||||
{
|
||||
auto_deallocate(base_type* alloc, node* dealloc, node* destr) :
|
||||
m_pAllocator(alloc),
|
||||
m_pDeallocate(dealloc),
|
||||
m_pDestroy(destr)
|
||||
{
|
||||
}
|
||||
~auto_deallocate()
|
||||
{
|
||||
m_pAllocator->deallocate(m_pDeallocate, 1);
|
||||
m_pDestroy->destroy();
|
||||
}
|
||||
|
||||
private:
|
||||
base_type* m_pAllocator;
|
||||
node* m_pDeallocate;
|
||||
node* m_pDestroy;
|
||||
};
|
||||
typedef threadsafe_queue_node< T > node;
|
||||
|
||||
public:
|
||||
typedef typename boost::log::aux::rebind_alloc< AllocatorT, node >::type allocator_type;
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef T const& const_reference;
|
||||
@@ -145,7 +122,33 @@ public:
|
||||
typedef T const* const_pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef AllocatorT allocator_type;
|
||||
|
||||
private:
|
||||
typedef boost::log::aux::allocator_traits< allocator_type > alloc_traits;
|
||||
|
||||
//! A simple scope guard to automate memory reclaiming
|
||||
struct auto_deallocate;
|
||||
friend struct auto_deallocate;
|
||||
struct auto_deallocate
|
||||
{
|
||||
auto_deallocate(allocator_type* alloc, node* dealloc, node* destr) BOOST_NOEXCEPT :
|
||||
m_pAllocator(alloc),
|
||||
m_pDeallocate(dealloc),
|
||||
m_pDestroy(destr)
|
||||
{
|
||||
}
|
||||
~auto_deallocate() BOOST_NOEXCEPT
|
||||
{
|
||||
alloc_traits::destroy(*m_pAllocator, m_pDeallocate);
|
||||
alloc_traits::deallocate(*m_pAllocator, m_pDeallocate, 1);
|
||||
m_pDestroy->destroy();
|
||||
}
|
||||
|
||||
private:
|
||||
allocator_type* m_pAllocator;
|
||||
node* m_pDeallocate;
|
||||
node* m_pDestroy;
|
||||
};
|
||||
|
||||
public:
|
||||
/*!
|
||||
@@ -154,28 +157,28 @@ public:
|
||||
*
|
||||
* \throw std::bad_alloc if there is not sufficient memory
|
||||
*/
|
||||
threadsafe_queue(base_type const& alloc = base_type()) :
|
||||
base_type(alloc)
|
||||
threadsafe_queue(allocator_type const& alloc = allocator_type()) :
|
||||
allocator_type(alloc)
|
||||
{
|
||||
node* p = base_type::allocate(1);
|
||||
node* p = alloc_traits::allocate(get_allocator(), 1);
|
||||
if (p)
|
||||
{
|
||||
try
|
||||
{
|
||||
new (p) node();
|
||||
alloc_traits::construct(get_allocator(), p);
|
||||
try
|
||||
{
|
||||
m_pImpl = threadsafe_queue_impl::create(p);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
p->~node();
|
||||
alloc_traits::destroy(get_allocator(), p);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
base_type::deallocate(p, 1);
|
||||
alloc_traits::deallocate(get_allocator(), p, 1);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -185,7 +188,7 @@ public:
|
||||
/*!
|
||||
* Destructor
|
||||
*/
|
||||
~threadsafe_queue()
|
||||
~threadsafe_queue() BOOST_NOEXCEPT
|
||||
{
|
||||
// Clear the queue
|
||||
if (!unsafe_empty())
|
||||
@@ -196,8 +199,8 @@ public:
|
||||
|
||||
// Remove the last dummy node
|
||||
node* p = static_cast< node* >(m_pImpl->reset_last_node());
|
||||
p->~node();
|
||||
base_type::deallocate(p, 1);
|
||||
alloc_traits::destroy(get_allocator(), p);
|
||||
alloc_traits::deallocate(get_allocator(), p, 1);
|
||||
|
||||
delete m_pImpl;
|
||||
}
|
||||
@@ -213,16 +216,16 @@ public:
|
||||
*/
|
||||
void push(const_reference value)
|
||||
{
|
||||
node* p = base_type::allocate(1);
|
||||
node* p = alloc_traits::allocate(get_allocator(), 1);
|
||||
if (p)
|
||||
{
|
||||
try
|
||||
{
|
||||
new (p) node(value);
|
||||
alloc_traits::construct(get_allocator(), p, value);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
base_type::deallocate(p, 1);
|
||||
alloc_traits::deallocate(get_allocator(), p, 1);
|
||||
throw;
|
||||
}
|
||||
m_pImpl->push(p);
|
||||
@@ -242,7 +245,7 @@ public:
|
||||
if (m_pImpl->try_pop(dealloc, destr))
|
||||
{
|
||||
node* p = static_cast< node* >(destr);
|
||||
auto_deallocate guard(static_cast< base_type* >(this), static_cast< node* >(dealloc), p);
|
||||
auto_deallocate guard(static_cast< allocator_type* >(this), static_cast< node* >(dealloc), p);
|
||||
value = boost::move(p->value());
|
||||
return true;
|
||||
}
|
||||
@@ -254,6 +257,10 @@ public:
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue(threadsafe_queue const&))
|
||||
BOOST_DELETED_FUNCTION(threadsafe_queue& operator= (threadsafe_queue const&))
|
||||
|
||||
private:
|
||||
//! Returns the allocator instance
|
||||
allocator_type& get_allocator() BOOST_NOEXCEPT { return *static_cast< allocator_type* >(this); }
|
||||
|
||||
private:
|
||||
//! Pointer to the implementation
|
||||
threadsafe_queue_impl* m_pImpl;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/log/detail/config.hpp>
|
||||
#if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
#include <boost/detail/winapi/basic_types.hpp>
|
||||
#include <boost/winapi/basic_types.hpp>
|
||||
#endif
|
||||
#include <boost/log/detail/header.hpp>
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
*/
|
||||
#if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
|
||||
|
||||
typedef uint64_t (WINAPI* get_tick_count_t)();
|
||||
typedef uint64_t (BOOST_WINAPI_WINAPI_CC* get_tick_count_t)();
|
||||
extern BOOST_LOG_API get_tick_count_t get_tick_count;
|
||||
|
||||
inline timestamp get_timestamp()
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright Andrey Semashev 2007 - 2015.
|
||||
* 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)
|
||||
*/
|
||||
/*!
|
||||
* \file unhandled_exception_count.hpp
|
||||
* \author Andrey Semashev
|
||||
* \date 05.11.2012
|
||||
*
|
||||
* \brief This header is the Boost.Log library implementation, see the library documentation
|
||||
* at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_LOG_DETAIL_UNHANDLED_EXCEPTION_COUNT_HPP_INCLUDED_
|
||||
#define BOOST_LOG_DETAIL_UNHANDLED_EXCEPTION_COUNT_HPP_INCLUDED_
|
||||
|
||||
#include <boost/log/detail/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
BOOST_LOG_OPEN_NAMESPACE
|
||||
|
||||
namespace aux {
|
||||
|
||||
//! Returns the number of currently pending exceptions
|
||||
BOOST_LOG_API unsigned int unhandled_exception_count() BOOST_NOEXCEPT;
|
||||
|
||||
} // namespace aux
|
||||
|
||||
BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_LOG_DETAIL_UNHANDLED_EXCEPTION_COUNT_HPP_INCLUDED_
|
||||
Reference in New Issue
Block a user