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)
13
13
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
14
14
endif ()
15
15
16
- if (MSVC AND LIBIPC_USE_STATIC_CRT )
16
+ if (MSVC )
17
17
set (CompilerFlags
18
18
CMAKE_CXX_FLAGS
19
19
CMAKE_CXX_FLAGS_DEBUG
@@ -22,9 +22,17 @@ if (MSVC AND LIBIPC_USE_STATIC_CRT)
22
22
CMAKE_C_FLAGS_DEBUG
23
23
CMAKE_C_FLAGS_RELEASE
24
24
)
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 ()
28
36
endif ()
29
37
30
38
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR} /bin )
@@ -50,6 +58,7 @@ endif()
50
58
if (LIBIPC_BUILD_DEMOS )
51
59
add_subdirectory (demo/chat )
52
60
add_subdirectory (demo/msg_que )
61
+ add_subdirectory (demo/send_recv )
53
62
endif ()
54
63
55
64
install (
Original file line number Diff line number Diff line change @@ -127,10 +127,10 @@ int main(int argc, char ** argv) {
127
127
::signal (SIGHUP , exit);
128
128
#endif
129
129
130
- if (std::string{ argv[1 ] } == mode_s__) {
130
+ std::string mode {argv[1 ]};
131
+ if (mode == mode_s__) {
131
132
do_send ();
132
- }
133
- else if (std::string{ argv[1 ] } == mode_r__) {
133
+ } else if (mode == mode_r__) {
134
134
do_recv ();
135
135
}
136
136
return 0 ;
Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ struct waiter_helper {
34
34
counter.waiting_ .fetch_add (1 , std::memory_order_release);
35
35
flags.is_waiting_ .store (true , std::memory_order_relaxed);
36
36
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
+ }
38
42
flags.is_waiting_ .store (false , std::memory_order_relaxed);
39
43
});
40
44
{
@@ -107,6 +111,7 @@ struct waiter_helper {
107
111
counter.counter_ -= 1 ;
108
112
ret = ret && ctrl.handshake_wait (tm);
109
113
} while (counter.counter_ > 0 );
114
+ counter.waiting_ .store (0 , std::memory_order_release);
110
115
}
111
116
return ret;
112
117
}
You can’t perform that action at this time.
0 commit comments