Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Reyhaneh Karimipour
xtrace-cpp
Commits
e0ad0219
Commit
e0ad0219
authored
May 17, 2019
by
DEPRECATED (Jonathan Mace) (Use @JonathanMace instead)
Browse files
Add simple example
parent
3b55fb93
Changes
2
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
e0ad0219
...
...
@@ -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
src/main.cc
0 → 100644
View file @
e0ad0219
#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
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment