C++ Logo

std-proposals

Advanced search

[std-proposals] scoped_lock to support variable number of locks determined during runtime

From: Bharath S <bharath.sekarp_at_[hidden]>
Date: Mon, 6 Feb 2023 23:16:13 -0500
Hello everyone,

std::scoped_lock taking in just a variadic mutexes is restrictive.
In one such scenario where there are jobs that are scheduled. These jobs
has their own set of tasks to achieve. These task can work on a set of
configurable inputs and outputs. The outputs of one of the task can be an
input of another task under a different job that is scheduled. Since these
are configurable, the mutexes creation is done during the process init and
job scheduling. Hence there is no way to use scoped_lock which is an
excellent addition to lock all or nothing mutexes that avoids deadlock.
How about an RAII for scoped_lock which takes a std container of mutexes
(or unique ptrs of mutexes). ? Is this a valid proposal? Am I missing
something that is already there and easy to use like scoped lock?

Regards
Bharath

Received on 2023-02-07 04:16:25