File tree Expand file tree Collapse file tree 3 files changed +22
-8
lines changed
Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ if(NOT MSVC)
1313 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
1414endif ()
1515
16- if (MSVC AND LIBIPC_USE_STATIC_CRT )
16+ if (MSVC )
1717 set (CompilerFlags
1818 CMAKE_CXX_FLAGS
1919 CMAKE_CXX_FLAGS_DEBUG
@@ -22,9 +22,17 @@ if (MSVC AND LIBIPC_USE_STATIC_CRT)
2222 CMAKE_C_FLAGS_DEBUG
2323 CMAKE_C_FLAGS_RELEASE
2424 )
25- foreach (CompilerFlag ${CompilerFlags} )
26- string (REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag} }" )
27- endforeach ()
25+ if (LIBIPC_USE_STATIC_CRT)
26+ foreach (CompilerFlag ${CompilerFlags} )
27+ string (REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag} }" )
28+ string (REPLACE "/MDd" "/MTd" ${CompilerFlag} "${${CompilerFlag} }" )
29+ endforeach ()
30+ else ()
31+ foreach (CompilerFlag ${CompilerFlags} )
32+ string (REPLACE "/MT" "/MD" ${CompilerFlag} "${${CompilerFlag} }" )
33+ string (REPLACE "/MTd" "/MDd" ${CompilerFlag} "${${CompilerFlag} }" )
34+ endforeach ()
35+ endif ()
2836endif ()
2937
3038set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR} /bin)
@@ -50,6 +58,7 @@ endif()
5058if (LIBIPC_BUILD_DEMOS)
5159 add_subdirectory (demo/chat)
5260 add_subdirectory (demo/msg_que)
61+ add_subdirectory (demo/send_recv)
5362endif ()
5463
5564install (
Original file line number Diff line number Diff line change @@ -127,10 +127,10 @@ int main(int argc, char ** argv) {
127127 ::signal (SIGHUP , exit);
128128#endif
129129
130- if (std::string{ argv[1 ] } == mode_s__) {
130+ std::string mode {argv[1 ]};
131+ if (mode == mode_s__) {
131132 do_send ();
132- }
133- else if (std::string{ argv[1 ] } == mode_r__) {
133+ } else if (mode == mode_r__) {
134134 do_recv ();
135135 }
136136 return 0 ;
Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ struct waiter_helper {
3434 counter.waiting_ .fetch_add (1 , std::memory_order_release);
3535 flags.is_waiting_ .store (true , std::memory_order_relaxed);
3636 auto finally = ipc::guard ([&counter, &flags] {
37- counter.waiting_ .fetch_sub (1 , std::memory_order_release);
37+ for (auto curr_wait = counter.waiting_ .load (std::memory_order_acquire); curr_wait > 0 ;) {
38+ if (counter.waiting_ .compare_exchange_weak (curr_wait, curr_wait - 1 , std::memory_order_release)) {
39+ break ;
40+ }
41+ }
3842 flags.is_waiting_ .store (false , std::memory_order_relaxed);
3943 });
4044 {
@@ -107,6 +111,7 @@ struct waiter_helper {
107111 counter.counter_ -= 1 ;
108112 ret = ret && ctrl.handshake_wait (tm);
109113 } while (counter.counter_ > 0 );
114+ counter.waiting_ .store (0 , std::memory_order_release);
110115 }
111116 return ret;
112117 }
You can’t perform that action at this time.
0 commit comments