1 | // |
2 | // immer: immutable data structures for C++ |
3 | // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente |
4 | // |
5 | // This software is distributed under the Boost Software License, Version 1.0. |
6 | // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt |
7 | // |
8 | |
9 | #pragma once |
10 | |
11 | namespace immer { |
12 | |
13 | struct disowned {}; |
14 | |
15 | struct no_spinlock |
16 | { |
17 | bool try_lock() { return true; } |
18 | void lock() {} |
19 | void unlock() {} |
20 | |
21 | struct scoped_lock |
22 | { |
23 | scoped_lock(no_spinlock&) {} |
24 | }; |
25 | }; |
26 | |
27 | /*! |
28 | * Disables reference counting, to be used with an alternative garbage |
29 | * collection strategy like a `gc_heap`. |
30 | */ |
31 | struct no_refcount_policy |
32 | { |
33 | using spinlock_type = no_spinlock; |
34 | |
35 | no_refcount_policy() {}; |
36 | no_refcount_policy(disowned) {} |
37 | |
38 | void inc() {} |
39 | bool dec() { return false; } |
40 | void dec_unsafe() {} |
41 | bool unique() { return false; } |
42 | }; |
43 | |
44 | } // namespace immer |
45 | |