
21 Jan
2010
21 Jan
'10
3 a.m.
I'm new to multi-threaded programming. So I apologize for aksing what is possibly a silly question. Will below code give me the behaviour of what is commonly called a "spinlock"? boost::unique_lock< boost::shared_mutex > guard( mutex, boost::try_to_lock ); if ( !guard.owns_lock() ) { while ( !guard.try_lock() ) { boost::thread::yield(); } } // access data Cheers, Moritz