mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-02 13:17:48 -04:00
Reduced SpinMutex scope in VisualProcessor::distribute()
This commit is contained in:
parent
5ab44e3104
commit
6afa3a6d6a
@ -133,11 +133,17 @@ protected:
|
|||||||
//* \param[in] errorMessage an error message written on std::cout in case pf push timeout.
|
//* \param[in] errorMessage an error message written on std::cout in case pf push timeout.
|
||||||
void distribute(OutputDataTypePtr item, std::uint64_t timeout = BLOCKING_INFINITE_TIMEOUT, const char* errorMessage = nullptr) {
|
void distribute(OutputDataTypePtr item, std::uint64_t timeout = BLOCKING_INFINITE_TIMEOUT, const char* errorMessage = nullptr) {
|
||||||
|
|
||||||
|
//scoped-lock: create a local copy of outputs, and work with it.
|
||||||
|
std::vector<VisualOutputQueueTypePtr> local_outputs;
|
||||||
|
{
|
||||||
std::lock_guard < SpinMutex > busy_lock(busy_update);
|
std::lock_guard < SpinMutex > busy_lock(busy_update);
|
||||||
//We will try to distribute 'output' among all 'outputs',
|
local_outputs = outputs;
|
||||||
//so 'output' will a-priori be shared among all 'outputs'.
|
}
|
||||||
|
|
||||||
for (VisualOutputQueueTypePtr single_output : outputs) {
|
//We will try to distribute 'output' among all 'local_outputs',
|
||||||
|
//so 'output' will a-priori be shared among all 'local_outputs'.
|
||||||
|
|
||||||
|
for (VisualOutputQueueTypePtr single_output : local_outputs) {
|
||||||
//'output' can fail to be given to an single_output,
|
//'output' can fail to be given to an single_output,
|
||||||
//using a blocking push, with a timeout
|
//using a blocking push, with a timeout
|
||||||
if (!(single_output)->push(item, timeout, errorMessage)) {
|
if (!(single_output)->push(item, timeout, errorMessage)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user