Пример #1
0
int main()
{
    {
    typedef std::shared_timed_mutex M;
	M m0;
	M m1;
    std::shared_lock<M> lk0(m0);
    std::shared_lock<M> lk1(m1);
    lk1 = std::move(lk0);
    assert(lk1.mutex() == std::addressof(m0));
    assert(lk1.owns_lock() == true);
    assert(lk0.mutex() == nullptr);
    assert(lk0.owns_lock() == false);
    }
    {
    typedef nasty_mutex M;
	M m0;
	M m1;
    std::shared_lock<M> lk0(m0);
    std::shared_lock<M> lk1(m1);
    lk1 = std::move(lk0);
    assert(lk1.mutex() == std::addressof(m0));
    assert(lk1.owns_lock() == true);
    assert(lk0.mutex() == nullptr);
    assert(lk0.owns_lock() == false);
    }
}
Пример #2
0
int main()
{
  {
  boost::shared_lock<boost::shared_mutex> lk0(m);
  boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock );
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::unique_lock<boost::shared_mutex> lk(boost::shared_lock<boost::shared_mutex>(m), boost::try_to_lock);
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  }
  {
  boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
  boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == false);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
  lk0.release();
  boost::unique_lock<boost::shared_mutex> lk(boost::move(lk0), boost::try_to_lock);
  BOOST_TEST(lk.mutex() == 0);
  BOOST_TEST(lk.owns_lock() == false);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }

  return boost::report_errors();
}
Пример #3
0
int tc_libcxx_thread_thread_lock_unique_cons_move_ctor(void)
{
    {
    typedef std::mutex M;
    M m;
    std::unique_lock<M> lk0(m);
    std::unique_lock<M> lk = std::move(lk0);
    TC_ASSERT_EXPR(lk.mutex() == std::addressof(m));
    TC_ASSERT_EXPR(lk.owns_lock() == true);
    TC_ASSERT_EXPR(lk0.mutex() == nullptr);
    TC_ASSERT_EXPR(lk0.owns_lock() == false);
    }
    {
    typedef nasty_mutex M;
    M m;
    std::unique_lock<M> lk0(m);
    std::unique_lock<M> lk = std::move(lk0);
    TC_ASSERT_EXPR(lk.mutex() == std::addressof(m));
    TC_ASSERT_EXPR(lk.owns_lock() == true);
    TC_ASSERT_EXPR(lk0.mutex() == nullptr);
    TC_ASSERT_EXPR(lk0.owns_lock() == false);
    }
    TC_SUCCESS_RESULT();
    return 0;
}
Пример #4
0
int main()
{
  {
  boost::unique_lock<boost::mutex> lk0(m);
  boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::unique_lock<boost::mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::unique_lock<boost::mutex>(m))));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  }
  {
  boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
  boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == false);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::unique_lock<boost::mutex> lk0(m, boost::defer_lock);
  lk0.release();
  boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
  BOOST_TEST(lk.mutex() == 0);
  BOOST_TEST(lk.owns_lock() == false);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }

  return boost::report_errors();
}
Пример #5
0
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    {
    typedef std::mutex M;
    M m;
    std::unique_lock<M> lk0(m);
    std::unique_lock<M> lk = std::move(lk0);
    assert(lk.mutex() == std::addressof(m));
    assert(lk.owns_lock() == true);
    assert(lk0.mutex() == nullptr);
    assert(lk0.owns_lock() == false);
    }
    {
    typedef nasty_mutex M;
    M m;
    std::unique_lock<M> lk0(m);
    std::unique_lock<M> lk = std::move(lk0);
    assert(lk.mutex() == std::addressof(m));
    assert(lk.owns_lock() == true);
    assert(lk0.mutex() == nullptr);
    assert(lk0.owns_lock() == false);
    }
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
Пример #6
0
int main()
{
  {
    boost::shared_lock<boost::shared_mutex> lk0(m0);
    boost::shared_lock<boost::shared_mutex> lk1(m1);
    lk1 = boost::move(lk0);
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }
  {

    boost::shared_lock<boost::shared_mutex> lk1;
    lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(m0));
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
  }
  {
    boost::unique_lock<boost::shared_mutex> lk0(m0);
    boost::shared_lock<boost::shared_mutex> lk1(m1);
    lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::move(lk0)));
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }
  {

    boost::shared_lock<boost::shared_mutex> lk1;
    lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::unique_lock<boost::shared_mutex>(m0)));
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
  }
  {
    boost::upgrade_lock<boost::shared_mutex> lk0(m0);
    boost::shared_lock<boost::shared_mutex> lk1(m1);
    lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::move(lk0)));
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }
  {

    boost::shared_lock<boost::shared_mutex> lk1;
    lk1 = BOOST_THREAD_MAKE_RV_REF(boost::shared_lock<boost::shared_mutex>(boost::upgrade_lock<boost::shared_mutex>(m0)));
    BOOST_TEST(lk1.mutex() == &m0);
    BOOST_TEST(lk1.owns_lock() == true);
  }
  return boost::report_errors();

}
Пример #7
0
int main()
{
  boost::strict_lock<boost::mutex> lk0(m0);
  boost::strict_lock<boost::mutex> lk1(m1);
  lk1 = lk0;

}
Пример #8
0
int main(int, char**)
{
    std::shared_lock<std::shared_timed_mutex> lk0(m);
    std::shared_lock<std::shared_timed_mutex> lk = lk0;

  return 0;
}
Пример #9
0
int main()
{
  boost::shared_lock_guard<boost::shared_mutex> lk0(m0);
  boost::shared_lock_guard<boost::shared_mutex> lk1(m1);
  lk1 = lk0;

}
int main()
{
  boost::lock_guard<boost::mutex> lk0(m0);
  boost::lock_guard<boost::mutex> lk1(m1);
  lk1 = lk0;

}
Пример #11
0
int main(int, char**)
{
    std::shared_lock<std::shared_timed_mutex> lk0(m0);
    std::shared_lock<std::shared_timed_mutex> lk1(m1);
    lk1 = lk0;

  return 0;
}
Пример #12
0
int main()
{
  boost::mutex m0;
  boost::unique_lock<boost::mutex> lk0(m0);
  {
    boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
    boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lg0);
  }
}
Пример #13
0
int main()
{
  boost::upgrade_lock<boost::shared_mutex> lk0(m0);
  boost::upgrade_lock<boost::shared_mutex> lk1(lk0);
  BOOST_TEST(lk1.mutex() == &m1);
  BOOST_TEST(lk1.owns_lock() == true);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
}
int main()
{
    boost::unique_lock<boost::mutex> lk0(m0);
    boost::unique_lock<boost::mutex> lk1 = lk0;
    BOOST_TEST(lk1.mutex() == &m1);
    BOOST_TEST(lk1.owns_lock() == true);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
}
Пример #15
0
int main()
{
#if _LIBCPP_STD_VER > 11
    std::shared_lock<std::shared_mutex> lk0(m0);
    std::shared_lock<std::shared_mutex> lk1(m1);
    lk1 = std::move(lk0);
    assert(lk1.mutex() == &m0);
    assert(lk1.owns_lock() == true);
    assert(lk0.mutex() == nullptr);
    assert(lk0.owns_lock() == false);
#endif  // _LIBCPP_STD_VER > 11
}
Пример #16
0
int main()
{
  boost::mutex m0;
  boost::mutex m1;
  boost::unique_lock<boost::mutex> lk0(m0);
  boost::unique_lock<boost::mutex> lk1(m1);
  {
    boost::reverse_lock<boost::unique_lock<boost::mutex> > lg0(lk0);
    boost::reverse_lock<boost::unique_lock<boost::mutex> > lg1(lk1);
    lg1 = lg0;
  }

}
int main()
{
  {
    boost::shared_lock<boost::shared_mutex> lk0(m);
    boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
    BOOST_TEST(lk.mutex() == &m);
    BOOST_TEST(lk.owns_lock() == true);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }
  {
    boost::upgrade_lock<boost::shared_mutex>
        lk( boost::shared_lock<boost::shared_mutex>(m), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
    BOOST_TEST(lk.mutex() == &m);
    BOOST_TEST(lk.owns_lock() == true);
  }
  {
    boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
    boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
    BOOST_TEST(lk.mutex() == &m);
    BOOST_TEST(lk.owns_lock() == false);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }
  {
    boost::shared_lock<boost::shared_mutex> lk0(m, boost::defer_lock);
    lk0.release();
    boost::upgrade_lock<boost::shared_mutex> lk( boost::move(lk0), boost::chrono::steady_clock::now()+boost::chrono::milliseconds(1));
    BOOST_TEST(lk.mutex() == 0);
    BOOST_TEST(lk.owns_lock() == false);
    BOOST_TEST(lk0.mutex() == 0);
    BOOST_TEST(lk0.owns_lock() == false);
  }

  return boost::report_errors();
}
Пример #18
0
int main()
{
  {
  boost::upgrade_lock<boost::shared_mutex> lk0(m);
  boost::upgrade_lock<boost::shared_mutex> lk( (boost::move(lk0)));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::upgrade_lock<boost::shared_mutex> lk( (BOOST_THREAD_MAKE_RV_REF(boost::upgrade_lock<boost::shared_mutex>(m))));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  }

  return boost::report_errors();
}
Пример #19
0
int main()
{
  {
  boost::unique_lock<boost::mutex> lk0(m);
  boost::unique_lock<boost::mutex> lk( (boost::move(lk0)));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  BOOST_TEST(lk0.mutex() == 0);
  BOOST_TEST(lk0.owns_lock() == false);
  }
  {
  boost::unique_lock<boost::mutex> lk( (boost::unique_lock<boost::mutex>(m)));
  BOOST_TEST(lk.mutex() == &m);
  BOOST_TEST(lk.owns_lock() == true);
  }

  return boost::report_errors();
}