From 510459c938cf19f24f529428b372df7a3e64b51c Mon Sep 17 00:00:00 2001 From: Barry Andrews Date: Mon, 22 Oct 2018 11:22:55 -0400 Subject: [PATCH] Fix build issues --- Release/CMakeLists.txt | 4 +++- Release/include/pplx/threadpool.h | 2 +- Release/src/json/json_parsing.cpp | 2 +- Release/src/pplx/threadpool.cpp | 36 ++----------------------------- 4 files changed, 7 insertions(+), 37 deletions(-) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 4bf08ef820..398ca41e73 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -115,6 +115,8 @@ endif() set(WARNINGS) set(ANDROID_STL_FLAGS) +add_definitions(-DBOOST_ALL_DYN_LINK) + # Platform (not compiler) specific settings if(IOS) # The cxx_flags must be reset here, because the ios-cmake toolchain file unfortunately sets "-headerpad_max_install_names" which is not a valid clang flag. @@ -208,7 +210,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP") - + if (WINDOWS_STORE OR WINDOWS_PHONE) add_compile_options(/ZW) endif() diff --git a/Release/include/pplx/threadpool.h b/Release/include/pplx/threadpool.h index dfa3344db8..2d3eb36005 100644 --- a/Release/include/pplx/threadpool.h +++ b/Release/include/pplx/threadpool.h @@ -66,7 +66,7 @@ class threadpool /// a diamond problem with multiple consumers attempting to customize the pool. /// /// Thrown if the threadpool has already been initialized - static void initialize_with_threads(size_t num_threads); + _ASYNCRTIMP static void initialize_with_threads(size_t num_threads); template CASABLANCA_DEPRECATED("Use `.service().post(task)` directly.") diff --git a/Release/src/json/json_parsing.cpp b/Release/src/json/json_parsing.cpp index a73a84b3ad..9863f0db5b 100644 --- a/Release/src/json/json_parsing.cpp +++ b/Release/src/json/json_parsing.cpp @@ -1029,7 +1029,7 @@ std::unique_ptr JSON_Parser::_ParseObject( ::std::sort(elems.begin(), elems.end(), json::object::compare_pairs); } - return obj; + return std::move(obj); error: if (!tkn.m_error) diff --git a/Release/src/pplx/threadpool.cpp b/Release/src/pplx/threadpool.cpp index 9bfeb398ba..cd6c1168ea 100644 --- a/Release/src/pplx/threadpool.cpp +++ b/Release/src/pplx/threadpool.cpp @@ -140,40 +140,8 @@ typedef threadpool_impl platform_shared_threadpool; std::pair initialize_shared_threadpool(size_t num_threads) { - static typename std::aligned_union<0, platform_shared_threadpool>::type storage; - platform_shared_threadpool* const ptr = - &reinterpret_cast(storage); - bool initialized_this_time = false; -#if defined(__ANDROID__) - // mutex based implementation due to paranoia about (lack of) call_once support on Android - // remove this if/when call_once is supported - static std::mutex mtx; - static std::atomic initialized; - abort_if_no_jvm(); - if (!initialized.load()) - { - std::lock_guard guard(mtx); - if (!initialized.load()) - { - ::new (static_cast(ptr)) platform_shared_threadpool(num_threads); - initialized.store(true); - initialized_this_time = true; - } - } // also unlock - -#else // ^^^ __ANDROID__ ^^^ // vvv !__ANDROID___ vvv // - static std::once_flag of; - -// #if defined(__ANDROID__) // if call_once can be used for android -// abort_if_no_jvm(); -// #endif // __ANDROID__ - std::call_once(of, [num_threads, ptr, &initialized_this_time] { - ::new (static_cast(ptr)) platform_shared_threadpool(num_threads); - initialized_this_time = true; - }); -#endif // __ANDROID__ - - return {initialized_this_time, ptr}; + static platform_shared_threadpool pool(num_threads); + return {true, &pool}; } }