diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-08-26 08:15:55 -0400 |
commit | bb4dd8289b351fae6b55e303f189127a394a1edd (patch) | |
tree | 77c9c35a31b1459dd7988c2448e797d142530c41 /libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp | |
parent | 1a78a62555be32868418fe52f8e330c9d0f95d5a (diff) | |
download | boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2 boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip |
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp')
-rwxr-xr-x | libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp new file mode 100755 index 0000000000..b7983bef34 --- /dev/null +++ b/libs/thread/test/sync/mutual_exclusion/locks/upgrade_lock/mod/non_member_swap_pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Copyright (C) 2011 Vicente J. Botet Escriba +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// <boost/thread/locks.hpp> + +// template <class Mutex> +// void swap(upgrade_lock<Mutex>& x, upgrade_lock<Mutex>& y); + +#include <boost/thread/locks.hpp> +#include <boost/detail/lightweight_test.hpp> + +struct shared_mutex +{ + void lock_upgrade() + { + } + void unlock_upgrade() + { + } +}; + +shared_mutex m; + +int main() +{ + boost::upgrade_lock<shared_mutex> lk1(m); + boost::upgrade_lock<shared_mutex> lk2; + swap(lk1, lk2); + BOOST_TEST(lk1.mutex() == 0); + BOOST_TEST(lk1.owns_lock() == false); + BOOST_TEST(lk2.mutex() == &m); + BOOST_TEST(lk2.owns_lock() == true); + + return boost::report_errors(); +} + |