Boost logo

Boost Users :

Subject: [Boost-users] [Atomic] [Tread] Proposal for Synchronized<T>
From: Gabriel Bizzotto (gbizzotto_at_[hidden])
Date: 2013-02-19 11:58:11


Hi ! I've created two simples classes that helped me avoid data races when sharing objects among threads. The idea is to declare objects that need for synchronization as Synchronized<T>, which holds a T and a mutex. To use the T, a Get function has to be called that returns a proxy, which holds a pointer to the T and a scoped lock on the mutex. The proxy defines operator-> and operator* to give access to the T. To have acces to the T, one has to create the proxy. As long as the proxy exists, the mutex associated with the T is locked, effectively preventing use by other threads. For more details and examples, I've already published the classes here http://codereview.stackexchange.com/questions/15632/force-locking-for-thread-safety/15742#15742  I find the scheme general purpose enough to fit the Atomic lib, or perhaps Thread. Please manifest yourselves if there is any interest in such device. Thx. Gabriel ++++++[>+++[>++++>++++++<<-]<-]>>-.>---.-------..>++++[<++++>-]<+. WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes) WebRep Classificação geral Este site não tem classificação (número de votos insuficientes)



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net