]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/thread/test/sync/mutual_exclusion/locks/shared_lock/locking/unlock_pass.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / thread / test / sync / mutual_exclusion / locks / shared_lock / locking / unlock_pass.cpp
CommitLineData
7c673cae
FG
1//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// Copyright (C) 2011 Vicente J. Botet Escriba
11//
12// Distributed under the Boost Software License, Version 1.0. (See accompanying
13// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
14
15// <boost/thread/locks.hpp>
16
17// template <class Mutex> class shared_lock;
18
19// template <class Rep, class Period>
20// bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
21
22#include <boost/thread/lock_types.hpp>
23//#include <boost/thread/shared_mutex.hpp>
24#include <boost/detail/lightweight_test.hpp>
25
26bool unlock_called = false;
27
28struct shared_mutex
29{
30 void lock_shared()
31 {
32 }
33 void unlock_shared()
34 {
35 unlock_called = true;
36 }
37};
38
39shared_mutex m;
40
41int main()
42{
43 boost::shared_lock<shared_mutex> lk(m);
44 lk.unlock();
45 BOOST_TEST(unlock_called == true);
46 BOOST_TEST(lk.owns_lock() == false);
47 try
48 {
49 lk.unlock();
50 BOOST_TEST(false);
51 }
52 catch (boost::system::system_error& e)
53 {
54 BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
55 }
56 lk.release();
57 try
58 {
59 lk.unlock();
60 BOOST_TEST(false);
61 }
62 catch (boost::system::system_error& e)
63 {
64 BOOST_TEST(e.code().value() == boost::system::errc::operation_not_permitted);
65 }
66
67 return boost::report_errors();
68}
69