Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 4d6222d

Browse files
committed
delete_persistent: extend doxygen documentation
Setting ptr to null after calling delete_persistent is required to ensure proper recovery.
1 parent 60109ca commit 4d6222d

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

examples/doc_snippets/make_persistent.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018, Intel Corporation
2+
* Copyright 2016-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -81,6 +81,10 @@ make_persistent_example()
8181

8282
// transactionally delete the object, ~compound_type() is called
8383
delete_persistent<compound_type>(proot->comp);
84+
85+
// set pointer to null so that after restart it's known whether
86+
// compound_type is still allocated or not
87+
proot->comp = nullptr;
8488
});
8589

8690
// throws an transaction_scope_error exception
@@ -139,6 +143,10 @@ make_persistent_array_example()
139143
// transactionally delete arrays , ~compound_type() is called
140144
delete_persistent<compound_type[]>(proot->comp, 20);
141145
delete_persistent<compound_type[3]>(arr1);
146+
147+
// set pointer to null so that after restart it's known whether
148+
// compound_type is still allocated or not
149+
proot->comp = nullptr;
142150
});
143151

144152
// throws an transaction_scope_error exception

include/libpmemobj++/make_persistent.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019, Intel Corporation
2+
* Copyright 2016-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -133,6 +133,9 @@ make_persistent(Args &&... args)
133133
* object's destructor before freeing memory. Cannot be used for array
134134
* types.
135135
*
136+
* To ensure that proper recovery is possible, ptr should be set to null after
137+
* delete_persistent call and within the same transaction.
138+
*
136139
* @param[in,out] ptr persistent pointer to an object that is not an
137140
* array.
138141
*

include/libpmemobj++/make_persistent_array.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019, Intel Corporation
2+
* Copyright 2016-2020, Intel Corporation
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -194,6 +194,9 @@ make_persistent(allocation_flag flag = allocation_flag::none())
194194
* objects. Calls the objects' destructors before freeing memory.
195195
* This overload only participates in overload resolution if T is an array.
196196
*
197+
* To ensure that proper recovery is possible, ptr should be set to null after
198+
* delete_persistent call and within the same transaction.
199+
*
197200
* @param[in,out] ptr persistent pointer to an array of objects.
198201
* @param[in] N the size of the array.
199202
*
@@ -238,6 +241,9 @@ delete_persistent(typename detail::pp_if_array<T>::type ptr, std::size_t N)
238241
* objects. Calls the objects' destructors before freeing memory.
239242
* This overload only participates in overload resolution if T is an array.
240243
*
244+
* To ensure that proper recovery is possible, ptr should be set to null after
245+
* delete_persistent call and within the same transaction.
246+
*
241247
* @param[in,out] ptr persistent pointer to an array of objects.
242248
*
243249
* @throw transaction_scope_error if called outside of an active

0 commit comments

Comments
 (0)