diff options
author | Bartosz Taudul <wolf@nereid.pl> | 2021-11-20 17:17:15 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf@nereid.pl> | 2021-11-20 19:09:20 +0300 |
commit | bcdbd2f7d7a90a1331c59f62ab8f366ac702567b (patch) | |
tree | 620b04fc64439b6fe4b0055cfabc45e09bd1a979 /examples | |
parent | b3562c99fb8d20f48573edc4ce39f44a806a91f2 (diff) |
Add simple fiber example.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/fibers.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/fibers.cpp b/examples/fibers.cpp new file mode 100644 index 00000000..6e3dbb5f --- /dev/null +++ b/examples/fibers.cpp @@ -0,0 +1,30 @@ +// g++ fibers.cpp ../TracyClient.cpp -DTRACY_ENABLE -DTRACY_FIBERS -lpthread -ldl + +#include <thread> +#include <unistd.h> + +#include "../Tracy.hpp" +#include "../TracyC.h" + +const char* fiber = "job1"; +TracyCZoneCtx zone; + +int main() +{ + std::thread t1( [] { + TracyFiberEnter( fiber ); + TracyCZone( ctx, 1 ); + zone = ctx; + sleep( 1 ); + TracyFiberLeave; + }); + t1.join(); + + std::thread t2( [] { + TracyFiberEnter( fiber ); + sleep( 1 ); + TracyCZoneEnd( zone ); + TracyFiberLeave; + }); + t2.join(); +} |