From 7f8f9785d7e9e120a6708d2f51e32dfef3e50c19 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 4 Mar 2015 11:46:31 +0100 Subject: ASyncRunStep doesn't need to lock when do setTimeOfDaySpeed. * setTimeOfDaySpeed already lock a mutex when modify the value, we don't need to lock all environment. * add a fine grain lock for getTimeOfDay and setTimeOfDay to solve environment multithread modifications on this value --- src/environment.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/environment.h') diff --git a/src/environment.h b/src/environment.h index 9eb440c42..761e9068b 100644 --- a/src/environment.h +++ b/src/environment.h @@ -81,22 +81,13 @@ public: u32 getDayNightRatio(); // 0-23999 - virtual void setTimeOfDay(u32 time) - { - m_time_of_day = time; - m_time_of_day_f = (float)time / 24000.0; - } - - u32 getTimeOfDay() - { return m_time_of_day; } - - float getTimeOfDayF() - { return m_time_of_day_f; } + virtual void setTimeOfDay(u32 time); + u32 getTimeOfDay(); + float getTimeOfDayF(); void stepTimeOfDay(float dtime); void setTimeOfDaySpeed(float speed); - float getTimeOfDaySpeed(); void setDayNightRatioOverride(bool enable, u32 value) @@ -134,7 +125,8 @@ protected: bool m_cache_enable_shaders; private: - JMutex m_lock; + JMutex m_timeofday_lock; + JMutex m_time_lock; }; -- cgit v1.2.3