summaryrefslogtreecommitdiff
path: root/src/environment.h
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2015-03-04 11:46:31 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2015-03-04 11:46:31 +0100
commit7f8f9785d7e9e120a6708d2f51e32dfef3e50c19 (patch)
tree454240229e803e8ca87a75e889fd54d3110ad426 /src/environment.h
parent1b2f64473ed4f222d3b7f02df853730d4382105e (diff)
downloadminetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.tar.gz
minetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.tar.bz2
minetest-7f8f9785d7e9e120a6708d2f51e32dfef3e50c19.zip
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
Diffstat (limited to 'src/environment.h')
-rw-r--r--src/environment.h18
1 files changed, 5 insertions, 13 deletions
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;
};