Cycles: Fix race condition happening in progress utility

This is not enough to mutex-guard modification code of integer values,
since this operation is NOT atomic. This is not even safe for a single
byte data types.

For now guarded the getter functions, similar to other functions in
this module.

Ideally we want to switch modification to an atomic operations, so we
wouldn't need any locks in the getters.
This commit is contained in:
Sergey Sharybin 2017-06-16 10:22:35 +02:00
parent 18e1c8d9fa
commit 794311c92b

@ -226,6 +226,7 @@ public:
int get_current_sample() int get_current_sample()
{ {
thread_scoped_lock lock(progress_mutex);
/* Note that the value here always belongs to the last tile that updated, /* Note that the value here always belongs to the last tile that updated,
* so it's only useful if there is only one active tile. */ * so it's only useful if there is only one active tile. */
return current_tile_sample; return current_tile_sample;
@ -233,11 +234,13 @@ public:
int get_rendered_tiles() int get_rendered_tiles()
{ {
thread_scoped_lock lock(progress_mutex);
return rendered_tiles; return rendered_tiles;
} }
int get_denoised_tiles() int get_denoised_tiles()
{ {
thread_scoped_lock lock(progress_mutex);
return denoised_tiles; return denoised_tiles;
} }