Date: Fri, 23 Feb 2024 14:28:59 -0300
It's hard to be transparent like that because thread safety isn't achieved
simply by adding mutexes to all methods.
For example, "find" can lock a mutex, search the container and unlock the
mutex, but it will return an iterator to the container.
What happens when that container is changed while the caller of "find" is
using the resulting iterator?
Em sex., 23 de fev. de 2024 14:21, David G. Pickett via Std-Proposals <
std-proposals_at_[hidden]> escreveu:
> It'd be nice if the language had a way to say that a particular container
> *instance* needs to be thread safe, so all methods are mutex protected.
> The developer could add a reserved word in the declaration. This way,
> users are not accidentally using a mutex unnecessarily. The compiler can
> add the mutex lock to all methods when invoked, somewhat like a MACRO but
> less global. We don't want to be like Java, and have to remember which
> container name is synchronized, e.g ArrayList, Vector; StringBuffer,
> StringBuilder, or hve duffers using a synchronized container when not
> needed.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
simply by adding mutexes to all methods.
For example, "find" can lock a mutex, search the container and unlock the
mutex, but it will return an iterator to the container.
What happens when that container is changed while the caller of "find" is
using the resulting iterator?
Em sex., 23 de fev. de 2024 14:21, David G. Pickett via Std-Proposals <
std-proposals_at_[hidden]> escreveu:
> It'd be nice if the language had a way to say that a particular container
> *instance* needs to be thread safe, so all methods are mutex protected.
> The developer could add a reserved word in the declaration. This way,
> users are not accidentally using a mutex unnecessarily. The compiler can
> add the mutex lock to all methods when invoked, somewhat like a MACRO but
> less global. We don't want to be like Java, and have to remember which
> container name is synchronized, e.g ArrayList, Vector; StringBuffer,
> StringBuilder, or hve duffers using a synchronized container when not
> needed.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2024-02-23 17:29:13