File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
libopenage/renderer/stages/world Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ void WorldObject::fetch_updates(const time::time_t &time) {
6262 }
6363
6464 // Get data from render entity
65+ auto read_lock = this ->render_entity ->get_read_lock ();
6566 this ->ref_id = this ->render_entity ->get_id ();
6667 this ->position .sync (this ->render_entity ->get_position ());
6768 this ->animation_info .sync (this ->render_entity ->get_animation_path (),
@@ -78,6 +79,7 @@ void WorldObject::fetch_updates(const time::time_t &time) {
7879 }),
7980 this ->last_update );
8081 this ->angle .sync (this ->render_entity ->get_angle (), this ->last_update );
82+ read_lock.unlock ();
8183
8284 // Set self to changed so that world renderer can update the renderable
8385 this ->changed = true ;
Original file line number Diff line number Diff line change @@ -96,4 +96,8 @@ void WorldRenderEntity::clear_changed_flag() {
9696 this ->changed = false ;
9797}
9898
99+ std::shared_lock<std::shared_mutex> WorldRenderEntity::get_read_lock () {
100+ return std::shared_lock{this ->mutex };
101+ }
102+
99103} // namespace openage::renderer::world
Original file line number Diff line number Diff line change 44
55#include < cstdint>
66#include < list>
7+ #include < mutex>
78#include < shared_mutex>
89#include < string>
910
@@ -105,6 +106,13 @@ class WorldRenderEntity {
105106 */
106107 void clear_changed_flag ();
107108
109+ /* *
110+ * Get a lock for thread-safe reading from the render entity.
111+ *
112+ * @return Lock for the render entity.
113+ */
114+ std::shared_lock<std::shared_mutex> get_read_lock ();
115+
108116private:
109117 /* *
110118 * Flag for determining if the render entity has been updated by the
You can’t perform that action at this time.
0 commit comments