1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Keep viewShutdown in atomic.

This commit is contained in:
Bartosz Taudul 2020-05-13 19:20:20 +02:00
parent 1fdae70cf8
commit b166451750

View File

@ -1,5 +1,6 @@
#include <algorithm>
#include <assert.h>
#include <atomic>
#include <chrono>
#include <inttypes.h>
#include <imgui.h>
@ -123,7 +124,7 @@ static ImFont* fixedWidth;
static char addr[1024] = { "127.0.0.1" };
static std::unordered_map<std::string, uint64_t> connHistMap;
static std::vector<std::unordered_map<std::string, uint64_t>::const_iterator> connHistVec;
static ViewShutdown viewShutdown = ViewShutdown::False;
static std::atomic<ViewShutdown> viewShutdown { ViewShutdown::False };
static double animTime = 0;
static float dpiScale = 1.f;
static ImGuiTextFilter addrFilter, portFilter, progFilter;
@ -794,7 +795,7 @@ static void DrawContents()
view->NotifyRootWindowSize( display_w, display_h );
if( !view->Draw() )
{
viewShutdown = ViewShutdown::True;
viewShutdown.store( ViewShutdown::True, std::memory_order_relaxed );
reconnect = view->ReconnectRequested();
if( reconnect )
{
@ -803,7 +804,7 @@ static void DrawContents()
}
loadThread = std::thread( [view = std::move( view )] () mutable {
view.reset();
viewShutdown = ViewShutdown::Join;
viewShutdown.store( ViewShutdown::Join, std::memory_order_relaxed );
} );
}
}
@ -880,14 +881,14 @@ static void DrawContents()
}
ImGui::EndPopup();
}
switch( viewShutdown )
switch( viewShutdown.load( std::memory_order_relaxed ) )
{
case ViewShutdown::True:
ImGui::OpenPopup( "Capture cleanup..." );
break;
case ViewShutdown::Join:
loadThread.join();
viewShutdown = ViewShutdown::False;
viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed );
if( reconnect )
{
view = std::make_unique<tracy::View>( reconnectAddr.c_str(), reconnectPort, fixedWidth, smallFont, bigFont, SetWindowTitleCallback );
@ -898,7 +899,7 @@ static void DrawContents()
}
if( ImGui::BeginPopupModal( "Capture cleanup...", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) )
{
if( viewShutdown != ViewShutdown::True ) ImGui::CloseCurrentPopup();
if( viewShutdown.load( std::memory_order_relaxed ) != ViewShutdown::True ) ImGui::CloseCurrentPopup();
tracy::TextCentered( ICON_FA_BROOM );
animTime += ImGui::GetIO().DeltaTime;
tracy::DrawWaitingDots( animTime );