N4033: synchronized_value for associating a mutex with a value -- Anthony Williams

A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4033

Date: 2014-05-23

synchronized_value for associating a mutex with a value

by Anthony Williams

Excerpt:

A couple of years ago I wrote an article for Dr Dobb's Journal discussing a synchronized_value template to associate a mutex with a value. I'd like to propose that template for standardization, with a few modifications.

The basic idea is that synchronized_value<T> stores a value of type T and a mutex. It then exposes a pointer interface, such that derefencing the pointer yields a special wrapper type that holds a lock on the mutex, and that can be implicitly converted to T for reading, and which forwards any values assigned to the assignment operator of the underlying T for writing. There is also an arrow operator which allows member functions on the wrapped value to be called...

Add a Comment

Comments are closed.

Comments (1)

0 0

andrew.somerville said on Jan 23, 2018 05:05 PM:

Did anything ever come of this?