PMDK C++ bindings  1.11.1
This is the C++ bindings documentation for PMDK's libpmemobj.
allocation_flag.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2019, Intel Corporation */
3 
9 #ifndef LIBPMEMOBJ_CPP_ALLOCATION_FLAG_HPP
10 #define LIBPMEMOBJ_CPP_ALLOCATION_FLAG_HPP
11 
12 #include <libpmemobj/base.h>
13 
14 namespace pmem
15 {
16 
17 namespace obj
18 {
19 
35  explicit allocation_flag(uint64_t val) : value(val)
36  {
37  }
38 
42  static allocation_flag
43  class_id(uint64_t id)
44  {
45  return allocation_flag(POBJ_CLASS_ID(id));
46  }
47 
51  static allocation_flag
53  {
54  return allocation_flag(POBJ_XALLOC_NO_FLUSH);
55  }
56 
60  static allocation_flag
61  none()
62  {
63  return allocation_flag(0);
64  }
65 
69  bool
70  is_set(const allocation_flag &rhs)
71  {
72  return (value & rhs.value) != 0;
73  }
74 
76  operator|(const allocation_flag &rhs)
77  {
78  return allocation_flag(value | rhs.value);
79  }
80 
81  uint64_t value;
82 };
83 
98  explicit allocation_flag_atomic(uint64_t val) : value(val)
99  {
100  }
101 
106  class_id(uint64_t id)
107  {
108  return allocation_flag_atomic(POBJ_CLASS_ID(id));
109  }
110 
116  {
117  return allocation_flag_atomic(0);
118  }
119 
123  bool
125  {
126  return (value & rhs.value) != 0;
127  }
128 
130  operator|(const allocation_flag_atomic &rhs)
131  {
132  return allocation_flag_atomic(value | rhs.value);
133  }
134 
135  uint64_t value;
136 };
137 
138 } /* namespace obj */
139 
140 } /* namespace pmem */
141 
142 #endif /* LIBPMEMOBJ_CPP_ALLOCATION_FLAG_HPP */
pmem::obj::allocation_flag::no_flush
static allocation_flag no_flush()
Skip flush on commit.
Definition: allocation_flag.hpp:52
pmem::obj::allocation_flag_atomic::allocation_flag_atomic
allocation_flag_atomic(uint64_t val)
Emplace constructor.
Definition: allocation_flag.hpp:98
pmem::obj::allocation_flag::allocation_flag
allocation_flag(uint64_t val)
Emplace constructor.
Definition: allocation_flag.hpp:35
pmem
Persistent memory namespace.
Definition: allocation_flag.hpp:15
pmem::obj::allocation_flag_atomic::class_id
static allocation_flag_atomic class_id(uint64_t id)
Allocate the object from the allocation class with id equal to id.
Definition: allocation_flag.hpp:106
pmem::obj::allocation_flag::is_set
bool is_set(const allocation_flag &rhs)
Check if flag is set.
Definition: allocation_flag.hpp:70
pmem::obj::allocation_flag_atomic
Type of flag which can be passed to make_persistent_atomic.
Definition: allocation_flag.hpp:94
pmem::obj::allocation_flag::class_id
static allocation_flag class_id(uint64_t id)
Allocate the object from the allocation class with id equal to id.
Definition: allocation_flag.hpp:43
pmem::obj::allocation_flag_atomic::none
static allocation_flag_atomic none()
Do not change allocator behaviour.
Definition: allocation_flag.hpp:115
pmem::obj::allocation_flag::none
static allocation_flag none()
Do not change allocator behaviour.
Definition: allocation_flag.hpp:61
pmem::obj::allocation_flag_atomic::is_set
bool is_set(const allocation_flag_atomic &rhs)
Check if flag is set.
Definition: allocation_flag.hpp:124
pmem::obj::allocation_flag
Type of flag which can be passed to make_persistent.
Definition: allocation_flag.hpp:31