diff --git a/.travis.yml b/.travis.yml index 5aee8f0..c7a33cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ matrix: compiler: gcc - os: osx compiler: clang + osx_image: xcode8 env: diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp index 7e01699..cf60a79 100644 --- a/include/chaiscript/chaiscript_defines.hpp +++ b/include/chaiscript/chaiscript_defines.hpp @@ -48,10 +48,6 @@ static_assert(_MSC_FULL_VER >= 190024210, "Visual C++ 2015 Update 3 or later req #endif #endif -#if defined(CHAISCRIPT_MSVC) || (defined(__GNUC__) && __GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || (defined(__llvm__) && !defined(CHAISCRIPT_LIBCPP)) -/// \todo Make this support other compilers when possible -#define CHAISCRIPT_HAS_THREAD_LOCAL -#endif #if defined(__llvm__) #define CHAISCRIPT_CLANG diff --git a/include/chaiscript/chaiscript_threading.hpp b/include/chaiscript/chaiscript_threading.hpp index 0d2825f..e8f097f 100644 --- a/include/chaiscript/chaiscript_threading.hpp +++ b/include/chaiscript/chaiscript_threading.hpp @@ -57,7 +57,6 @@ namespace chaiscript using std::recursive_mutex; -#ifdef CHAISCRIPT_HAS_THREAD_LOCAL /// Typesafe thread specific storage. If threading is enabled, this class uses a mutex protected map. If /// threading is not enabled, the class always returns the same data, regardless of which thread it is called from. template @@ -106,69 +105,6 @@ namespace chaiscript } }; -#else - -#pragma message ("Threading without thread_local support is not well supported.") - - - /// Typesafe thread specific storage. If threading is enabled, this class uses a mutex protected map. If - /// threading is not enabled, the class always returns the same data, regardless of which thread it is called from. - /// - /// This version is used if the compiler does not support thread_local - template - class Thread_Storage - { - public: - - explicit Thread_Storage(void *) - { - } - - inline const T *operator->() const - { - return get_tls().get(); - } - - inline const T &operator*() const - { - return *get_tls(); - } - - inline T *operator->() - { - return get_tls().get(); - } - - inline T &operator*() - { - return *get_tls(); - } - - - private: - /// \todo this leaks thread instances. It needs to be culled from time to time - std::shared_ptr get_tls() const - { - unique_lock lock(m_mutex); - - const auto id = std::this_thread::get_id(); - auto itr = m_instances.find(id); - - if (itr != m_instances.end()) { return itr->second; } - - std::shared_ptr new_instance(std::make_shared()); - - m_instances.insert(std::make_pair(id, new_instance)); - - return new_instance; - } - - - mutable mutex m_mutex; - mutable std::unordered_map > m_instances; - }; -#endif // threading enabled but no tls - #else // threading disabled template class unique_lock