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) {
62
62
}
63
63
64
64
// Get data from render entity
65
+ auto read_lock = this ->render_entity ->get_read_lock ();
65
66
this ->ref_id = this ->render_entity ->get_id ();
66
67
this ->position .sync (this ->render_entity ->get_position ());
67
68
this ->animation_info .sync (this ->render_entity ->get_animation_path (),
@@ -78,6 +79,7 @@ void WorldObject::fetch_updates(const time::time_t &time) {
78
79
}),
79
80
this ->last_update );
80
81
this ->angle .sync (this ->render_entity ->get_angle (), this ->last_update );
82
+ read_lock.unlock ();
81
83
82
84
// Set self to changed so that world renderer can update the renderable
83
85
this ->changed = true ;
Original file line number Diff line number Diff line change @@ -96,4 +96,8 @@ void WorldRenderEntity::clear_changed_flag() {
96
96
this ->changed = false ;
97
97
}
98
98
99
+ std::shared_lock<std::shared_mutex> WorldRenderEntity::get_read_lock () {
100
+ return std::shared_lock{this ->mutex };
101
+ }
102
+
99
103
} // namespace openage::renderer::world
Original file line number Diff line number Diff line change 4
4
5
5
#include < cstdint>
6
6
#include < list>
7
+ #include < mutex>
7
8
#include < shared_mutex>
8
9
#include < string>
9
10
@@ -105,6 +106,13 @@ class WorldRenderEntity {
105
106
*/
106
107
void clear_changed_flag ();
107
108
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
+
108
116
private:
109
117
/* *
110
118
* Flag for determining if the render entity has been updated by the
You can’t perform that action at this time.
0 commit comments