00708edd107482c2b29e4720d4bbccf5c9d38e9d
[libcds.git] / cds / urcu / options.h
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
29 */
30
31 #ifndef CDSLIB_URCU_OPTIONS_H
32 #define CDSLIB_URCU_OPTIONS_H
33
34 #include <cds/details/defs.h>
35
36 namespace cds { namespace urcu {
37     /// Exception "RCU deadlock detected"
38     /**@anchor cds_urcu_rcu_deadlock
39         This exception is raised when \p cds::opt::v::rcu_throw_deadlock deadlock checking policy
40         is used, see \p cds::opt::rcu_check_deadlock option.
41     */
42     class rcu_deadlock: public std::logic_error
43     {
44         //@cond
45     public:
46         rcu_deadlock()
47             : std::logic_error( "RCU deadlock detected" )
48         {}
49         //@endcond
50     };
51 }} // namespace cds::urcu
52
53
54 namespace cds { namespace opt {
55
56     /// [type-option] RCU check deadlock option setter
57     /**
58         The RCU containers can check if a deadlock between read-side critical section
59         and \p synchronize call is possible.
60         This option specifies a policy for checking this situation.
61         Possible \p Type is:
62         - \p opt::v::rcu_no_check_deadlock - no deadlock checking
63         - \p opt::v::rcu_assert_deadlock - call \p assert in debug mode only
64         - \p opt::v::rcu_throw_deadlock - throw an \p cds::urcu::rcu_deadlock exception when a deadlock
65             is encountered
66
67         Usually, the default \p Type for this option is \p opt::v::rcu_throw_deadlock.
68     */
69     template <typename Type>
70     struct rcu_check_deadlock
71     {
72         //@cond
73         template <typename Base> struct pack: public Base
74         {
75             typedef Type rcu_check_deadlock;
76         };
77         //@endcond
78     };
79
80     namespace v {
81         /// \ref opt::rcu_check_deadlock option value: no deadlock checking
82         struct rcu_no_check_deadlock {};
83
84         /// \ref opt::rcu_check_deadlock option value: call \p assert in debug mode only
85         struct rcu_assert_deadlock {};
86
87         /// \ref opt::rcu_check_deadlock option value: throw a cds::urcu::rcu_deadlock exception when a deadlock detected
88         struct rcu_throw_deadlock {};
89     }
90 }}  // namespace cds::opt
91
92
93 #endif  // #ifndef CDSLIB_URCU_OPTIONS_H