File tree 3 files changed +32
-4
lines changed
3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -101,4 +101,7 @@ option(CPPZMQ_BUILD_TESTS "Whether or not to build the tests" ON)
101
101
if (CPPZMQ_BUILD_TESTS)
102
102
enable_testing ()
103
103
add_subdirectory (tests)
104
+ if (CMAKE_CXX_STANDARD AND NOT CMAKE_CXX_STANDARD EQUAL 98 AND CMAKE_CXX_STANDARD GREATER_EQUAL 11)
105
+ add_subdirectory (examples)
106
+ endif ()
104
107
endif ()
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.0 FATAL_ERROR)
2
+
3
+ project (cppzmq-examples CXX)
4
+
5
+ # place binaries and libraries according to GNU standards
6
+
7
+ include (GNUInstallDirs)
8
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
9
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
10
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_BINDIR} )
11
+
12
+ find_package (Threads)
13
+
14
+ add_executable (
15
+ pubsub_multithread_inproc
16
+ pubsub_multithread_inproc.cpp
17
+ )
18
+
19
+ target_link_libraries (
20
+ pubsub_multithread_inproc
21
+ PRIVATE cppzmq
22
+ PRIVATE ${CMAKE_THREAD_LIBS_INIT}
23
+ )
Original file line number Diff line number Diff line change @@ -40,9 +40,10 @@ void SubscriberThread1(zmq::context_t *ctx) {
40
40
zmq::recv_result_t result =
41
41
zmq::recv_multipart (subscriber, std::back_inserter (recv_msgs));
42
42
assert (result && " recv failed" );
43
+ assert (*result == 2 );
43
44
44
- std::cout << " Thread2: [" << recv_msgs[0 ].to_string_view () << " ] "
45
- << recv_msgs[1 ].to_string_view () << std::endl;
45
+ std::cout << " Thread2: [" << recv_msgs[0 ].to_string () << " ] "
46
+ << recv_msgs[1 ].to_string () << std::endl;
46
47
}
47
48
}
48
49
@@ -60,9 +61,10 @@ void SubscriberThread2(zmq::context_t *ctx) {
60
61
zmq::recv_result_t result =
61
62
zmq::recv_multipart (subscriber, std::back_inserter (recv_msgs));
62
63
assert (result && " recv failed" );
64
+ assert (*result == 2 );
63
65
64
- std::cout << " Thread3: [" << recv_msgs[0 ].to_string_view () << " ] "
65
- << recv_msgs[1 ].to_string_view () << std::endl;
66
+ std::cout << " Thread3: [" << recv_msgs[0 ].to_string () << " ] "
67
+ << recv_msgs[1 ].to_string () << std::endl;
66
68
}
67
69
}
68
70
You can’t perform that action at this time.
0 commit comments