/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2016-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
// Abnormal case
hazptr_array<HAZPTR_TC_SIZE + 1> h;
+ hazptr_array<HAZPTR_TC_SIZE + 1> h2(std::move(h));
}
}
CHECK_EQ(constructed.load(), num);
CHECK_EQ(destroyed.load(), num);
}
+
+TEST_F(HazptrTest, FreeFunctionRetire) {
+ auto foo = new int;
+ hazptr_retire(foo);
+ auto foo2 = new int;
+ hazptr_retire(foo2, [](int* obj) { delete obj; });
+
+ bool retired = false;
+ {
+ hazptr_domain myDomain0;
+ struct delret {
+ bool* retired_;
+ delret(bool* retire) : retired_(retire) {}
+ ~delret() {
+ *retired_ = true;
+ }
+ };
+ auto foo3 = new delret(&retired);
+ myDomain0.retire(foo3);
+ }
+ EXPECT_TRUE(retired);
+}