¡@

Home 

c++ Programming Glossary: mmutex

Need some feedback on how to make a class “thread-safe”

http://stackoverflow.com/questions/3482352/need-some-feedback-on-how-to-make-a-class-thread-safe

getGame return mGame.get boost mutex getMutex const return mMutex private boost scoped_ptr Game mGame mutable boost mutex mMutex.. private boost scoped_ptr Game mGame mutable boost mutex mMutex Usage example assuming threadSafeGame is pointer to a ThreadSafeGame.. boost scoped_ptr Game mGame mutable boost mutex mMutex class ThreadSafeGame public ThreadSafeGame std auto_ptr Game..

How to use lock_guard when returning protected data

http://stackoverflow.com/questions/3856729/how-to-use-lock-guard-when-returning-protected-data

Data Class GetData boost lock_guard boost mutex lock this mMutex return this mData Would this be correct if mData is the variable.. this be correct if mData is the variable protected by mMutex Or would I have to use a local scope and a temporary like shown.. GetData Data ret boost lock_guard boost mutex lock this mMutex ret this mData return ret c multithreading locking thread safety..