Commit e0ad0219 authored by DEPRECATED (Jonathan Mace) (Use @JonathanMace instead)'s avatar DEPRECATED (Jonathan Mace) (Use @JonathanMace instead)
Browse files

Add simple example

parent 3b55fb93
......@@ -29,6 +29,9 @@ set_target_properties(libxtrace
)
target_link_libraries(libxtrace Threads::Threads ${Protobuf_LIBRARIES} ${Boost_LIBRARIES} )
add_executable (main src/main.cc )
target_link_libraries(main libxtrace)
# Introduce variables:
# * CMAKE_INSTALL_LIBDIR
# * CMAKE_INSTALL_BINDIR
......@@ -43,4 +46,4 @@ install(DIRECTORY "include"
PATTERN "*.h")
install(TARGETS libxtrace DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(TARGETS libxtrace DESTINATION "${CMAKE_INSTALL_LIBDIR}")
\ No newline at end of file
#include <iostream>
#include <vector>
#include "atomlayer.h"
#include "pubsub.h"
#include <sstream>
#include "xtrace_baggage.h"
#include "lexvarint.h"
#include "baggageprotocol.h"
#include "thread_local_baggage.h"
#include "xtrace.h"
void test_vector(std::vector<int> testv) {
testv[0] = 5;
std::cout << testv[0] << std::endl;
}
void printvector(std::vector<uint8_t> bytes) {
for (unsigned i = 0; i < bytes.size(); i++) {
std::cout << int(bytes[i]) << " ";
}
std::cout << std::endl;
}
int main(int argc, char *argv[]) {
XTrace::StartTrace("main.cc");
XTRACE("a");
XTRACE("b");
XTRACE("c");
Baggage branched_baggage = ThreadLocalBaggage::Branch();
std::thread branched_thread([&branched_baggage]() {
ThreadLocalBaggage::Set(branched_baggage);
XTRACE("f");
XTRACE("g");
branched_baggage = ThreadLocalBaggage::Take();
});
XTRACE("d");
XTRACE("e");
branched_thread.join();
ThreadLocalBaggage::Join(branched_baggage);
XTRACE("h");
PubSub::shutdown();
PubSub::join();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment