diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-09-20 18:36:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2016-09-20 11:45:52 +0200 |
commit | 3e826f8897170caee4b8a51a8346c71cb767984d (patch) | |
tree | 5b45b22ae11af7e88aee6821d2a137a56cab609d /vcl/inc/opengl/watchdog.hxx | |
parent | e1954f5ba5f637c9df801401db3630c8e1138ccf (diff) |
tdf#102295: remove mutex - use atomic for watchdog timings
Change-Id: I6587bad8b7906faeae39735343278b10be78c05b
Diffstat (limited to 'vcl/inc/opengl/watchdog.hxx')
-rw-r--r-- | vcl/inc/opengl/watchdog.hxx | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/vcl/inc/opengl/watchdog.hxx b/vcl/inc/opengl/watchdog.hxx index ced3cf23fbd6..c266de62f7dc 100644 --- a/vcl/inc/opengl/watchdog.hxx +++ b/vcl/inc/opengl/watchdog.hxx @@ -14,40 +14,42 @@ #include <sal/types.h> #include <rtl/ref.hxx> #include <salhelper/thread.hxx> -#include <osl/mutex.hxx> +#include <atomic> -struct WatchdogTimings +struct WatchdogTimingsValues { - osl::Mutex maMutex; - - int mnMode; - /// delays to take various actions in 1/4 of a second increments. - std::vector<int> maDisableEntries; - std::vector<int> maAbortAfter; + int mnDisableEntries; + int mnAbortAfter; +}; - WatchdogTimings(); +enum class WatchdogTimingMode +{ + NORMAL, + SHADER_COMPILE +}; - void relax(); +class WatchdogTimings +{ +private: + std::vector<WatchdogTimingsValues> maTimingValues; + std::atomic<bool> mbRelaxed; - int getMode() - { - return mnMode; - } +public: + WatchdogTimings(); - void setMode(int nMode) + void setRelax(bool bRelaxed) { - mnMode = nMode; + mbRelaxed = bRelaxed; } - int getDisableEntries() + WatchdogTimingsValues getWatchdogTimingsValues(WatchdogTimingMode eMode) { - return maDisableEntries[mnMode]; - } + size_t index = 0; + index = (eMode == WatchdogTimingMode::SHADER_COMPILE) ? 1 : 0; + index = mbRelaxed ? index + 2 : index; - int getAbortAfter() - { - return maAbortAfter[mnMode]; + return maTimingValues[index]; } }; |