Skip to content

Commit

Permalink
Remove -latomic dependency because Linux gcc loads that at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
fpw committed Nov 4, 2018
1 parent 5979af2 commit 4609bba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ target_link_libraries(avitab_common

if(WIN32)
target_link_libraries(avitab_common
atomic
ws2_32
)
endif(WIN32)
Expand Down
9 changes: 7 additions & 2 deletions src/environment/xplane/XPlaneEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ float XPlaneEnvironment::onFlightLoop(float elapsedSinceLastCall, float elapseSi
loc.latitude = dataCache.getData("sim/flightmodel/position/latitude").doubleValue;
loc.longitude = dataCache.getData("sim/flightmodel/position/longitude").doubleValue;
loc.heading = dataCache.getData("sim/flightmodel/position/psi").floatValue;
aircraftLocation.store(loc);

{
std::lock_guard<std::mutex> lock(stateMutex);
aircraftLocation = loc;
}

lastDrawTime = dataCache.getData("sim/operation/misc/frame_rate_period").floatValue;

Expand All @@ -261,7 +265,8 @@ float XPlaneEnvironment::onFlightLoop(float elapsedSinceLastCall, float elapseSi
}

Location XPlaneEnvironment::getAircraftLocation() {
return aircraftLocation.load();
std::lock_guard<std::mutex> lock(stateMutex);
return aircraftLocation;
}

float XPlaneEnvironment::getLastFrameTime() {
Expand Down
4 changes: 3 additions & 1 deletion src/environment/xplane/XPlaneEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <vector>
#include <atomic>
#include <map>
#include <thread>
#include "src/gui_toolkit/LVGLToolkit.h"
#include "src/environment/Environment.h"
#include "DataCache.h"
Expand Down Expand Up @@ -68,10 +69,11 @@ class XPlaneEnvironment: public Environment {
DataCache dataCache;
std::string pluginPath, xplaneRootPath;
std::shared_ptr<xdata::XData> xplaneData;
std::atomic<Location> aircraftLocation{};
Location aircraftLocation{};
std::atomic<float> lastDrawTime{};

// State
std::mutex stateMutex;
std::vector<MenuCallback> menuCallbacks;
std::atomic<XPLMFlightLoopID> flightLoopId { nullptr };
std::map<XPLMCommandRef, RegisteredCommand> commandHandlers;
Expand Down

0 comments on commit 4609bba

Please sign in to comment.