I would like to control access to getters and setters for a bunch of data classes to make them safely accessible from multiple threads at the same time. I already did this in Java using java.util.concurrent.locks.ReentrantReadWriteLock, and it was pretty painless.
But now I have a lot of problems in my current C ++ project, because I cannot find a reimplementation of read / write lock. In particular, I want a stream to allow a stream to receive a read lock if it already has a write lock, without a lock, and without giving up write lock.
The reason is simple: some of my setter methods call getter methods, and the former (usually) get write locks, and the latter read locks. I don't want to distort my straightforward getter / setter architecture in order to get around the restrictions in lock classes.
I tried Qt (4.8) QReadWriteLock and its related classes and Boost unique_lock and shared_lock. None of the libraries implements the update I need. Does any other part of Boost use this?
Or is there another library that has this? I'm really surprised that neither Qt nor Boost look like they seem to be such a clearly desirable feature. (And which has been part of the Java standard library since 2004.)
java c ++ multithreading boost qt
Chris
source share