Skip to content

Commit 9185140

Browse files
Merge pull request #1 from bandrews-spirent/many-threads
Fix build issues
2 parents ada8e57 + 510459c commit 9185140

File tree

4 files changed

+7
-37
lines changed

4 files changed

+7
-37
lines changed

Release/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ endif()
115115
set(WARNINGS)
116116
set(ANDROID_STL_FLAGS)
117117

118+
add_definitions(-DBOOST_ALL_DYN_LINK)
119+
118120
# Platform (not compiler) specific settings
119121
if(IOS)
120122
# 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")
208210
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP")
209211
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP")
210212
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP")
211-
213+
212214
if (WINDOWS_STORE OR WINDOWS_PHONE)
213215
add_compile_options(/ZW)
214216
endif()

Release/include/pplx/threadpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class threadpool
6666
/// a diamond problem with multiple consumers attempting to customize the pool.
6767
/// </remarks>
6868
/// <exception cref="std::exception">Thrown if the threadpool has already been initialized</exception>
69-
static void initialize_with_threads(size_t num_threads);
69+
_ASYNCRTIMP static void initialize_with_threads(size_t num_threads);
7070

7171
template<typename T>
7272
CASABLANCA_DEPRECATED("Use `.service().post(task)` directly.")

Release/src/json/json_parsing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseObject(
10291029
::std::sort(elems.begin(), elems.end(), json::object::compare_pairs);
10301030
}
10311031

1032-
return obj;
1032+
return std::move(obj);
10331033

10341034
error:
10351035
if (!tkn.m_error)

Release/src/pplx/threadpool.cpp

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -140,40 +140,8 @@ typedef threadpool_impl platform_shared_threadpool;
140140

141141
std::pair<bool, platform_shared_threadpool*> initialize_shared_threadpool(size_t num_threads)
142142
{
143-
static typename std::aligned_union<0, platform_shared_threadpool>::type storage;
144-
platform_shared_threadpool* const ptr =
145-
&reinterpret_cast<platform_shared_threadpool&>(storage);
146-
bool initialized_this_time = false;
147-
#if defined(__ANDROID__)
148-
// mutex based implementation due to paranoia about (lack of) call_once support on Android
149-
// remove this if/when call_once is supported
150-
static std::mutex mtx;
151-
static std::atomic<bool> initialized;
152-
abort_if_no_jvm();
153-
if (!initialized.load())
154-
{
155-
std::lock_guard<std::mutex> guard(mtx);
156-
if (!initialized.load())
157-
{
158-
::new (static_cast<void*>(ptr)) platform_shared_threadpool(num_threads);
159-
initialized.store(true);
160-
initialized_this_time = true;
161-
}
162-
} // also unlock
163-
164-
#else // ^^^ __ANDROID__ ^^^ // vvv !__ANDROID___ vvv //
165-
static std::once_flag of;
166-
167-
// #if defined(__ANDROID__) // if call_once can be used for android
168-
// abort_if_no_jvm();
169-
// #endif // __ANDROID__
170-
std::call_once(of, [num_threads, ptr, &initialized_this_time] {
171-
::new (static_cast<void*>(ptr)) platform_shared_threadpool(num_threads);
172-
initialized_this_time = true;
173-
});
174-
#endif // __ANDROID__
175-
176-
return {initialized_this_time, ptr};
143+
static platform_shared_threadpool pool(num_threads);
144+
return {true, &pool};
177145
}
178146
}
179147

0 commit comments

Comments
 (0)