1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Resolves potential data race on write_area_texture_.

This commit is contained in:
Thomas Harte 2020-02-18 22:41:46 -05:00
parent 91e7400bbb
commit 3715e6b48a
2 changed files with 5 additions and 4 deletions

View File

@ -180,13 +180,13 @@ uint8_t *ScanTarget::begin_data(size_t required_length, size_t required_alignmen
assert(required_alignment);
if(allocation_has_failed_) return nullptr;
std::lock_guard<std::mutex> lock_guard(write_pointers_mutex_);
if(write_area_texture_.empty()) {
allocation_has_failed_ = true;
return nullptr;
}
std::lock_guard<std::mutex> lock_guard(write_pointers_mutex_);
// Determine where the proposed write area would start and end.
uint16_t output_y = TextureAddressGetY(write_pointers_.write_area);

View File

@ -116,8 +116,9 @@ class ScanTarget: public Outputs::Display::ScanTarget {
/// A pointer to the next thing that should be provided to the caller for data.
PointerSet write_pointers_;
/// A mutex for gettng access to write_pointers_; access to write_pointers_
/// or data_type_size_ is almost never contended, so this is cheap for the main use case.
/// A mutex for gettng access to write_pointers_; access to write_pointers_,
/// data_type_size_ or write_area_texture_ is almost never contended, so this
/// is cheap for the main use case.
std::mutex write_pointers_mutex_;
/// A pointer to the final thing currently cleared for submission.