|
Boost Users : |
Subject: [Boost-users] Q: N00b spinlock
From: Moritz Moeller (boost_at_[hidden])
Date: 2010-01-20 22:00:35
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
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