Add simple fiber example.

This commit is contained in:
Bartosz Taudul 2021-11-20 15:17:15 +01:00
parent b3562c99fb
commit bcdbd2f7d7
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

30
examples/fibers.cpp Normal file
View File

@ -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();
}