Enable use of shared_mutex now on C++14
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
#ifndef CHAISCRIPT_NO_THREADS
|
#ifndef CHAISCRIPT_NO_THREADS
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <shared_mutex>
|
||||||
#else
|
#else
|
||||||
#ifndef CHAISCRIPT_NO_THREADS_WARNING
|
#ifndef CHAISCRIPT_NO_THREADS_WARNING
|
||||||
#pragma message ("ChaiScript is compiling without thread safety.")
|
#pragma message ("ChaiScript is compiling without thread safety.")
|
||||||
@@ -42,28 +43,16 @@ namespace chaiscript
|
|||||||
#ifndef CHAISCRIPT_NO_THREADS
|
#ifndef CHAISCRIPT_NO_THREADS
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class unique_lock : public std::unique_lock<T>
|
using unique_lock = std::unique_lock<T>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit unique_lock(T &t) : std::unique_lock<T>(t) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class shared_lock : public std::unique_lock<T>
|
using shared_lock = std::shared_lock<T>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit shared_lock(T &t) : std::unique_lock<T>(t) {}
|
|
||||||
void unlock() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class lock_guard : public std::lock_guard<T>
|
using lock_guard = std::lock_guard<T>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit lock_guard(T &t) : std::lock_guard<T>(t) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class shared_mutex : public std::mutex { };
|
|
||||||
|
using shared_mutex = std::shared_timed_mutex;
|
||||||
|
|
||||||
using std::mutex;
|
using std::mutex;
|
||||||
|
|
||||||
|
@@ -28,10 +28,10 @@ namespace chaiscript {
|
|||||||
|
|
||||||
bad_any_cast(const bad_any_cast &) = default;
|
bad_any_cast(const bad_any_cast &) = default;
|
||||||
|
|
||||||
virtual ~bad_any_cast() noexcept {}
|
~bad_any_cast() noexcept override = default;
|
||||||
|
|
||||||
/// \brief Description of what error occurred
|
/// \brief Description of what error occurred
|
||||||
virtual const char * what() const noexcept override
|
const char * what() const noexcept override
|
||||||
{
|
{
|
||||||
return m_what.c_str();
|
return m_what.c_str();
|
||||||
}
|
}
|
||||||
@@ -53,9 +53,10 @@ namespace chaiscript {
|
|||||||
|
|
||||||
Data &operator=(const Data &) = delete;
|
Data &operator=(const Data &) = delete;
|
||||||
|
|
||||||
virtual ~Data() {}
|
virtual ~Data() = default;
|
||||||
|
|
||||||
virtual void *data() = 0;
|
virtual void *data() = 0;
|
||||||
|
|
||||||
const std::type_info &type() const
|
const std::type_info &type() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return m_type;
|
||||||
@@ -74,8 +75,6 @@ namespace chaiscript {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Data_Impl() {}
|
|
||||||
|
|
||||||
virtual void *data() override
|
virtual void *data() override
|
||||||
{
|
{
|
||||||
return &m_data;
|
return &m_data;
|
||||||
@@ -96,6 +95,8 @@ namespace chaiscript {
|
|||||||
public:
|
public:
|
||||||
// construct/copy/destruct
|
// construct/copy/destruct
|
||||||
Any() = default;
|
Any() = default;
|
||||||
|
Any(Any &&) = default;
|
||||||
|
Any &operator=(Any &&t_any) = default;
|
||||||
|
|
||||||
Any(const Any &t_any)
|
Any(const Any &t_any)
|
||||||
{
|
{
|
||||||
@@ -107,8 +108,6 @@ namespace chaiscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Any(Any &&) = default;
|
|
||||||
Any &operator=(Any &&t_any) = default;
|
|
||||||
|
|
||||||
template<typename ValueType,
|
template<typename ValueType,
|
||||||
typename = typename std::enable_if<!std::is_same<Any, typename std::decay<ValueType>::type>::value>::type>
|
typename = typename std::enable_if<!std::is_same<Any, typename std::decay<ValueType>::type>::value>::type>
|
||||||
@@ -137,10 +136,6 @@ namespace chaiscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~Any()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
Any & swap(Any &t_other)
|
Any & swap(Any &t_other)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user