Skip to content

Commit

Permalink
Merge pull request microsoft#1 from bandrews-spirent/many-threads
Browse files Browse the repository at this point in the history
Fix build issues
  • Loading branch information
bandrews-spirent authored Oct 22, 2018
2 parents ada8e57 + 510459c commit 9185140
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 37 deletions.
4 changes: 3 additions & 1 deletion Release/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Release/include/pplx/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class threadpool
/// a diamond problem with multiple consumers attempting to customize the pool.
/// </remarks>
/// <exception cref="std::exception">Thrown if the threadpool has already been initialized</exception>
static void initialize_with_threads(size_t num_threads);
_ASYNCRTIMP static void initialize_with_threads(size_t num_threads);

template<typename T>
CASABLANCA_DEPRECATED("Use `.service().post(task)` directly.")
Expand Down
2 changes: 1 addition & 1 deletion Release/src/json/json_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseObject(
::std::sort(elems.begin(), elems.end(), json::object::compare_pairs);
}

return obj;
return std::move(obj);

error:
if (!tkn.m_error)
Expand Down
36 changes: 2 additions & 34 deletions Release/src/pplx/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,8 @@ typedef threadpool_impl platform_shared_threadpool;

std::pair<bool, platform_shared_threadpool*> 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<platform_shared_threadpool&>(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<bool> initialized;
abort_if_no_jvm();
if (!initialized.load())
{
std::lock_guard<std::mutex> guard(mtx);
if (!initialized.load())
{
::new (static_cast<void*>(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<void*>(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};
}
}

Expand Down

0 comments on commit 9185140

Please sign in to comment.