diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp | |
parent | Initial commit. (diff) | |
download | ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp')
-rw-r--r-- | src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp b/src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp new file mode 100644 index 000000000..c39ca50aa --- /dev/null +++ b/src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/mod/release_pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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> class shared_lock; + +// void Mutex* release(); + +#include <boost/thread/lock_types.hpp> +#include <boost/detail/lightweight_test.hpp> + +struct shared_mutex +{ + static int lock_count; + static int unlock_count; + void lock_shared() + { + ++lock_count; + } + void unlock_shared() + { + ++unlock_count; + } +}; + +int shared_mutex::lock_count = 0; +int shared_mutex::unlock_count = 0; + +shared_mutex m; + +int main() +{ + boost::shared_lock<shared_mutex> lk(m); + BOOST_TEST(lk.mutex() == &m); + BOOST_TEST(lk.owns_lock() == true); + BOOST_TEST(shared_mutex::lock_count == 1); + BOOST_TEST(shared_mutex::unlock_count == 0); + BOOST_TEST(lk.release() == &m); + BOOST_TEST(lk.mutex() == 0); + BOOST_TEST(lk.owns_lock() == false); + BOOST_TEST(shared_mutex::lock_count == 1); + BOOST_TEST(shared_mutex::unlock_count == 0); + + return boost::report_errors(); +} + |