mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-11-11 03:43:52 +01:00
* fix race condition in Fifo::FreeAddress
(cherry picked from commit dd5b2360d6)
This commit is contained in:
1 parent
853f48b7fe
commit
6ee4239659
2 files changed
+8
-1
No files matched your search
@@ -81,7 +81,10 @@ void Fifo::DestroyFifos() {
|
||||
fifoStream = nullptr;
|
||||
}
|
||||
|
||||
void Fifo::FreeAddress(char *&address) { fifoFree->push(address); }
|
||||
void Fifo::FreeAddress(char *&address) {
|
||||
std::lock_guard<std::mutex> lock(fifoFreeMutex);
|
||||
fifoFree->push(address);
|
||||
}
|
||||
|
||||
void Fifo::GetNewAddress(char *&address) {
|
||||
int temp = fifoFree->getDataValue();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "sls/sls_detector_defs.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@@ -52,6 +53,9 @@ class Fifo : private virtual slsDetectorDefs {
|
||||
int fifoDepth;
|
||||
std::atomic<int> status_fifoBound;
|
||||
std::atomic<int> status_fifoFree;
|
||||
/** fifoFree has several producers, CircularFifo allows only one.
|
||||
* Aligned to avoid false sharing with the members above */
|
||||
alignas(128) std::mutex fifoFreeMutex;
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
Reference in new issue
Block a user