mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Resolves potential data race on write_area_texture_.
This commit is contained in:
parent
91e7400bbb
commit
3715e6b48a
@ -180,13 +180,13 @@ uint8_t *ScanTarget::begin_data(size_t required_length, size_t required_alignmen
|
|||||||
assert(required_alignment);
|
assert(required_alignment);
|
||||||
|
|
||||||
if(allocation_has_failed_) return nullptr;
|
if(allocation_has_failed_) return nullptr;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock_guard(write_pointers_mutex_);
|
||||||
if(write_area_texture_.empty()) {
|
if(write_area_texture_.empty()) {
|
||||||
allocation_has_failed_ = true;
|
allocation_has_failed_ = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock_guard(write_pointers_mutex_);
|
|
||||||
|
|
||||||
// Determine where the proposed write area would start and end.
|
// Determine where the proposed write area would start and end.
|
||||||
uint16_t output_y = TextureAddressGetY(write_pointers_.write_area);
|
uint16_t output_y = TextureAddressGetY(write_pointers_.write_area);
|
||||||
|
|
||||||
|
@ -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.
|
/// A pointer to the next thing that should be provided to the caller for data.
|
||||||
PointerSet write_pointers_;
|
PointerSet write_pointers_;
|
||||||
|
|
||||||
/// A mutex for gettng access to write_pointers_; access to 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.
|
/// 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_;
|
std::mutex write_pointers_mutex_;
|
||||||
|
|
||||||
/// A pointer to the final thing currently cleared for submission.
|
/// A pointer to the final thing currently cleared for submission.
|
||||||
|
Loading…
Reference in New Issue
Block a user