bool try_lock() { HPX_ITT_SYNC_PREPARE(this); if (m.try_lock()) { HPX_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } HPX_ITT_SYNC_CANCEL(this); return false; }
int main() { BOOST_TEST( sp.try_lock() ); BOOST_TEST( !sp.try_lock() ); BOOST_TEST( sp2.try_lock() ); BOOST_TEST( !sp.try_lock() ); BOOST_TEST( !sp2.try_lock() ); sp.unlock(); sp2.unlock(); sp.lock(); BOOST_TEST( !sp.try_lock() ); sp2.lock(); BOOST_TEST( !sp.try_lock() ); BOOST_TEST( !sp2.try_lock() ); sp.unlock(); sp2.unlock(); { boost::detail::spinlock::scoped_lock lock( sp ); BOOST_TEST( !sp.try_lock() ); boost::detail::spinlock::scoped_lock lock2( sp2 ); BOOST_TEST( !sp.try_lock() ); BOOST_TEST( !sp2.try_lock() ); } return boost::report_errors(); }