Summary: There are still some upstream references to `folly::make_unique` that need to be removed before it can be full killed, but this gets it most of the way there.
Reviewed By: yfeldblum
Differential Revision:
D5024310
fbshipit-source-id:
6cfe8ea93662be18bb55588c8200dec72946e205
42 files changed:
* after the call.
*/
bool insertHead(T t) {
* after the call.
*/
bool insertHead(T t) {
- auto wrapper = folly::make_unique<Wrapper>(std::move(t));
+ auto wrapper = std::make_unique<Wrapper>(std::move(t));
return list_.insertHead(wrapper.release());
}
return list_.insertHead(wrapper.release());
}
} else if (t.hasException()) {
contains_ = Contains::EXCEPTION;
new (&e_) std::unique_ptr<exception_wrapper>(
} else if (t.hasException()) {
contains_ = Contains::EXCEPTION;
new (&e_) std::unique_ptr<exception_wrapper>(
- folly::make_unique<exception_wrapper>(t.exception()));
+ std::make_unique<exception_wrapper>(t.exception()));
new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>();
new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>();
- e_ = folly::make_unique<exception_wrapper>(*(t.e_));
+ e_ = std::make_unique<exception_wrapper>(*(t.e_));
new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>();
new (&value_)T(t.value_);
} else if (contains_ == Contains::EXCEPTION) {
new (&e_)std::unique_ptr<exception_wrapper>();
- e_ = folly::make_unique<exception_wrapper>(*(t.e_));
+ e_ = std::make_unique<exception_wrapper>(*(t.e_));
* @param e The exception_wrapper
*/
explicit Try(exception_wrapper e)
* @param e The exception_wrapper
*/
explicit Try(exception_wrapper e)
- : contains_(Contains::EXCEPTION),
- e_(folly::make_unique<exception_wrapper>(std::move(e))) {}
+ : contains_(Contains::EXCEPTION),
+ e_(std::make_unique<exception_wrapper>(std::move(e))) {}
try {
std::rethrow_exception(ep);
} catch (const std::exception& e) {
try {
std::rethrow_exception(ep);
} catch (const std::exception& e) {
- e_ = folly::make_unique<exception_wrapper>(std::current_exception(), e);
+ e_ = std::make_unique<exception_wrapper>(std::current_exception(), e);
- e_ = folly::make_unique<exception_wrapper>(std::current_exception());
+ e_ = std::make_unique<exception_wrapper>(std::current_exception());
* @param e The exception_wrapper
*/
explicit Try(exception_wrapper e)
* @param e The exception_wrapper
*/
explicit Try(exception_wrapper e)
- : hasValue_(false),
- e_(folly::make_unique<exception_wrapper>(std::move(e))) {}
+ : hasValue_(false),
+ e_(std::make_unique<exception_wrapper>(std::move(e))) {}
try {
std::rethrow_exception(ep);
} catch (const std::exception& e) {
try {
std::rethrow_exception(ep);
} catch (const std::exception& e) {
- e_ = folly::make_unique<exception_wrapper>(std::current_exception(), e);
+ e_ = std::make_unique<exception_wrapper>(std::current_exception(), e);
- e_ = folly::make_unique<exception_wrapper>(std::current_exception());
+ e_ = std::make_unique<exception_wrapper>(std::current_exception());
Try& operator=(const Try<void>& t) {
hasValue_ = t.hasValue_;
if (t.e_) {
Try& operator=(const Try<void>& t) {
hasValue_ = t.hasValue_;
if (t.e_) {
- e_ = folly::make_unique<exception_wrapper>(*t.e_);
+ e_ = std::make_unique<exception_wrapper>(*t.e_);
fs::path dir,
Scope scope)
: scope_(scope),
fs::path dir,
Scope scope)
: scope_(scope),
- path_(folly::make_unique<fs::path>(
+ path_(std::make_unique<fs::path>(
generateUniquePath(std::move(dir), namePrefix))) {
fs::create_directory(path());
}
generateUniquePath(std::move(dir), namePrefix))) {
fs::create_directory(path());
}
typedef FutureDAG::Handle Handle;
Handle add() {
typedef FutureDAG::Handle Handle;
Handle add() {
- auto node = folly::make_unique<TestNode>(this);
+ auto node = std::make_unique<TestNode>(this);
auto handle = node->handle;
nodes.emplace(handle, std::move(node));
return handle;
auto handle = node->handle;
nodes.emplace(handle, std::move(node));
return handle;
template<typename> class WeakPtr,
size_t threadCount>
void benchmark(size_t n) {
template<typename> class WeakPtr,
size_t threadCount>
void benchmark(size_t n) {
- MainPtr<int> mainPtr(folly::make_unique<int>(42));
+ MainPtr<int> mainPtr(std::make_unique<int>(42));
std::vector<std::thread> ts;
std::vector<std::thread> ts;
// Store 1.
std::atomic<int> cnt1{0};
// Store 1.
std::atomic<int> cnt1{0};
- ptr.reset(folly::make_unique<TestObject>(1, cnt1));
+ ptr.reset(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, cnt1.load());
// Store 2, check that 1 is destroyed.
std::atomic<int> cnt2{0};
EXPECT_EQ(1, cnt1.load());
// Store 2, check that 1 is destroyed.
std::atomic<int> cnt2{0};
- ptr.reset(folly::make_unique<TestObject>(2, cnt2));
+ ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(0, cnt1.load());
EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(0, cnt1.load());
EXPECT_EQ(ptr.get(), nullptr);
std::atomic<int> cnt1{0};
EXPECT_EQ(ptr.get(), nullptr);
std::atomic<int> cnt1{0};
- ptr.reset(folly::make_unique<TestObject>(1, cnt1));
+ ptr.reset(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, cnt1.load());
x = ptr;
EXPECT_EQ(1, x->value);
EXPECT_EQ(1, cnt1.load());
x = ptr;
EXPECT_EQ(1, x->value);
- ptr.reset(folly::make_unique<TestObject>(2, cnt2));
+ ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(1, cnt1.load());
EXPECT_EQ(1, cnt2.load());
EXPECT_EQ(1, cnt1.load());
loads[0].requestAndWait();
loads[0].requestAndWait();
- ptr.reset(folly::make_unique<TestObject>(1, cnt));
+ ptr.reset(std::make_unique<TestObject>(1, cnt));
loads[1].requestAndWait();
loads[1].requestAndWait();
- ptr.reset(folly::make_unique<TestObject>(2, cnt));
+ ptr.reset(std::make_unique<TestObject>(2, cnt));
loads[2].requestAndWait();
loads[3].requestAndWait();
loads[2].requestAndWait();
loads[3].requestAndWait();
- ptr.reset(folly::make_unique<TestObject>(3, cnt));
- ptr.reset(folly::make_unique<TestObject>(4, cnt));
+ ptr.reset(std::make_unique<TestObject>(3, cnt));
+ ptr.reset(std::make_unique<TestObject>(4, cnt));
loads[4].requestAndWait();
loads[4].requestAndWait();
- ptr.reset(folly::make_unique<TestObject>(5, cnt));
+ ptr.reset(std::make_unique<TestObject>(5, cnt));
loads[5].requestAndWait();
loads[6].requestAndWait();
loads[5].requestAndWait();
loads[6].requestAndWait();
TEST_F(ReadMostlySharedPtrTest, Ctor) {
std::atomic<int> cnt1{0};
{
TEST_F(ReadMostlySharedPtrTest, Ctor) {
std::atomic<int> cnt1{0};
{
- ReadMostlyMainPtr<TestObject> ptr(
- folly::make_unique<TestObject>(1, cnt1));
+ ReadMostlyMainPtr<TestObject> ptr(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, ptr.getShared()->value);
}
EXPECT_EQ(1, ptr.getShared()->value);
}
ReadMostlyMainPtr<TestObject> ptr;
// Store 1.
ReadMostlyMainPtr<TestObject> ptr;
// Store 1.
- ptr.reset(folly::make_unique<TestObject>(1, cnt1));
+ ptr.reset(std::make_unique<TestObject>(1, cnt1));
EXPECT_EQ(1, cnt1.load());
// Store 2 and check that 1 is destroyed.
EXPECT_EQ(1, cnt1.load());
// Store 2 and check that 1 is destroyed.
- ptr.reset(folly::make_unique<TestObject>(2, cnt2));
+ ptr.reset(std::make_unique<TestObject>(2, cnt2));
EXPECT_EQ(0, cnt1.load());
// Unblock thread.
EXPECT_EQ(0, cnt1.load());
// Unblock thread.
expectTempdirExists(d);
expectTempdirExists(d2);
expectTempdirExists(d);
expectTempdirExists(d2);
- dir = folly::make_unique<TemporaryDirectory>(std::move(d));
+ dir = std::make_unique<TemporaryDirectory>(std::move(d));
- stack_ = folly::make_unique<AltStackBuffer>();
+ stack_ = std::make_unique<AltStackBuffer>();
setAlternateStack(stack_->data(), stack_->size());
}
setAlternateStack(stack_->data(), stack_->size());
}
auto currentFm = getFiberManagerUnsafe();
if (currentFm && currentFm->currentFiber_ &&
currentFm->localType_ == localType_) {
auto currentFm = getFiberManagerUnsafe();
if (currentFm && currentFm->currentFiber_ &&
currentFm->localType_ == localType_) {
- return folly::make_unique<RemoteTask>(
+ return std::make_unique<RemoteTask>(
std::forward<F>(func), currentFm->currentFiber_->localData_);
}
std::forward<F>(func), currentFm->currentFiber_->localData_);
}
- return folly::make_unique<RemoteTask>(std::forward<F>(func));
+ return std::make_unique<RemoteTask>(std::forward<F>(func));
}();
auto insertHead = [&]() {
return remoteTaskQueue_.insertHead(task.release());
}();
auto insertHead = [&]() {
return remoteTaskQueue_.insertHead(task.release());
template <typename F>
RemoteTask(F&& f, const Fiber::LocalData& localData_)
: func(std::forward<F>(f)),
template <typename F>
RemoteTask(F&& f, const Fiber::LocalData& localData_)
: func(std::forward<F>(f)),
- localData(folly::make_unique<Fiber::LocalData>(localData_)),
+ localData(std::make_unique<Fiber::LocalData>(localData_)),
rcontext(RequestContext::saveContext()) {}
folly::Function<void()> func;
std::unique_ptr<Fiber::LocalData> localData;
rcontext(RequestContext::saveContext()) {}
folly::Function<void()> func;
std::unique_ptr<Fiber::LocalData> localData;
std::lock_guard<folly::SpinLock> lg(lock_);
if (inUse_ < kMaxInUse) {
++inUse_;
std::lock_guard<folly::SpinLock> lg(lock_);
if (inUse_ < kMaxInUse) {
++inUse_;
- return folly::make_unique<StackCacheEntry>(stackSize);
+ return std::make_unique<StackCacheEntry>(stackSize);
class StackCacheEntry {
public:
explicit StackCacheEntry(size_t stackSize)
class StackCacheEntry {
public:
explicit StackCacheEntry(size_t stackSize)
- : stackCache_(folly::make_unique<StackCache>(stackSize)) {}
+ : stackCache_(std::make_unique<StackCache>(stackSize)) {}
StackCache& cache() const noexcept {
return *stackCache_;
StackCache& cache() const noexcept {
return *stackCache_;
}
timeoutHandleBuckets_.emplace_back(
}
timeoutHandleBuckets_.emplace_back(
- duration, folly::make_unique<TimeoutHandleList>());
+ duration, std::make_unique<TimeoutHandleList>());
return *timeoutHandleBuckets_.back().second;
}();
return *timeoutHandleBuckets_.back().second;
}();
void runBenchmark(size_t numAwaits, size_t toSend) {
sNumAwaits = numAwaits;
void runBenchmark(size_t numAwaits, size_t toSend) {
sNumAwaits = numAwaits;
- FiberManager fiberManager(folly::make_unique<SimpleLoopController>());
+ FiberManager fiberManager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
FiberManager::Options opts;
opts.maxFibersPoolSize = 0;
FiberManager::Options opts;
opts.maxFibersPoolSize = 0;
- FiberManager fiberManager(folly::make_unique<SimpleLoopController>(), opts);
+ FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize());
for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize());
FiberManager::Options opts;
opts.maxFibersPoolSize = 0;
FiberManager::Options opts;
opts.maxFibersPoolSize = 0;
- FiberManager fiberManager(folly::make_unique<SimpleLoopController>(), opts);
+ FiberManager fiberManager(std::make_unique<SimpleLoopController>(), opts);
for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize());
for (size_t iter = 0; iter < iters; ++iter) {
DCHECK_EQ(0, fiberManager.fibersPoolSize());
bool taskAdded = false;
size_t iterations = 0;
bool taskAdded = false;
size_t iterations = 0;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
size_t iterations = 0;
Baton* baton_ptr;
size_t iterations = 0;
Baton* baton_ptr;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
- FiberManager manager(folly::make_unique<EventBaseLoopController>());
+ FiberManager manager(std::make_unique<EventBaseLoopController>());
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
- FiberManager manager(folly::make_unique<EventBaseLoopController>());
+ FiberManager manager(std::make_unique<EventBaseLoopController>());
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
}
TEST(FiberManager, batonTryWait) {
}
TEST(FiberManager, batonTryWait) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
// Check if try_wait and post work as expected
Baton b;
// Check if try_wait and post work as expected
Baton b;
}
TEST(FiberManager, genericBatonFiberWait) {
}
TEST(FiberManager, genericBatonFiberWait) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
GenericBaton b;
bool fiberRunning = false;
GenericBaton b;
bool fiberRunning = false;
}
TEST(FiberManager, genericBatonThreadWait) {
}
TEST(FiberManager, genericBatonThreadWait) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
GenericBaton b;
std::atomic<bool> threadWaiting(false);
GenericBaton b;
std::atomic<bool> threadWaiting(false);
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
await([&pendingFibers](Promise<int> promise) {
pendingFibers.push_back(std::move(promise));
});
await([&pendingFibers](Promise<int> promise) {
pendingFibers.push_back(std::move(promise));
});
- return folly::make_unique<int>(i * 2 + 1);
+ return std::make_unique<int>(i * 2 + 1);
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
std::vector<Promise<int>> pendingFibers;
bool taskAdded = false;
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
}
TEST(FiberManager, runInMainContext) {
}
TEST(FiberManager, runInMainContext) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
}
TEST(FiberManager, addTaskFinally) {
}
TEST(FiberManager, addTaskFinally) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
FiberManager::Options opts;
opts.maxFibersPoolSize = 5;
FiberManager::Options opts;
opts.maxFibersPoolSize = 5;
- FiberManager manager(folly::make_unique<SimpleLoopController>(), opts);
+ FiberManager manager(std::make_unique<SimpleLoopController>(), opts);
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
FiberManager::Options opts;
opts.maxFibersPoolSize = 5;
FiberManager::Options opts;
opts.maxFibersPoolSize = 5;
- FiberManager manager(folly::make_unique<SimpleLoopController>(), opts);
+ FiberManager manager(std::make_unique<SimpleLoopController>(), opts);
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
}
TEST(FiberManager, remoteFiberBasic) {
}
TEST(FiberManager, remoteFiberBasic) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
}
TEST(FiberManager, addTaskRemoteBasic) {
}
TEST(FiberManager, addTaskRemoteBasic) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
int result[2];
result[0] = result[1] = 0;
int result[2];
result[0] = result[1] = 0;
TEST(FiberManager, remoteHasTasks) {
size_t counter = 0;
TEST(FiberManager, remoteHasTasks) {
size_t counter = 0;
- FiberManager fm(folly::make_unique<SimpleLoopController>());
+ FiberManager fm(std::make_unique<SimpleLoopController>());
std::thread remote([&]() { fm.addTaskRemote([&]() { ++counter; }); });
remote.join();
std::thread remote([&]() { fm.addTaskRemote([&]() { ++counter; }); });
remote.join();
TEST(FiberManager, remoteHasReadyTasks) {
int result = 0;
folly::Optional<Promise<int>> savedPromise;
TEST(FiberManager, remoteHasReadyTasks) {
int result = 0;
folly::Optional<Promise<int>> savedPromise;
- FiberManager fm(folly::make_unique<SimpleLoopController>());
+ FiberManager fm(std::make_unique<SimpleLoopController>());
std::thread remote([&]() {
fm.addTaskRemote([&]() {
result = await(
std::thread remote([&]() {
fm.addTaskRemote([&]() {
result = await(
template <typename Data>
void testFiberLocal() {
template <typename Data>
void testFiberLocal() {
- FiberManager fm(
- LocalType<Data>(), folly::make_unique<SimpleLoopController>());
+ FiberManager fm(LocalType<Data>(), std::make_unique<SimpleLoopController>());
fm.addTask([]() {
EXPECT_EQ(42, local<Data>().value);
fm.addTask([]() {
EXPECT_EQ(42, local<Data>().value);
- LocalType<CrazyData>(), folly::make_unique<SimpleLoopController>());
+ LocalType<CrazyData>(), std::make_unique<SimpleLoopController>());
fm.addTask([]() { local<CrazyData>().data = 41; });
fm.addTask([]() { local<CrazyData>().data = 41; });
}
TEST(FiberManager, yieldTest) {
}
TEST(FiberManager, yieldTest) {
- FiberManager manager(folly::make_unique<SimpleLoopController>());
+ FiberManager manager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(manager.loopController());
}
TEST(FiberManager, RequestContext) {
}
TEST(FiberManager, RequestContext) {
- FiberManager fm(folly::make_unique<SimpleLoopController>());
+ FiberManager fm(std::make_unique<SimpleLoopController>());
bool checkRun1 = false;
bool checkRun2 = false;
bool checkRun1 = false;
bool checkRun2 = false;
opts.fibersPoolResizePeriodMs = 300;
opts.maxFibersPoolSize = 5;
opts.fibersPoolResizePeriodMs = 300;
opts.maxFibersPoolSize = 5;
- FiberManager manager(folly::make_unique<EventBaseLoopController>(), opts);
+ FiberManager manager(std::make_unique<EventBaseLoopController>(), opts);
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
}
TEST(FiberManager, batonWaitTimeoutHandler) {
}
TEST(FiberManager, batonWaitTimeoutHandler) {
- FiberManager manager(folly::make_unique<EventBaseLoopController>());
+ FiberManager manager(std::make_unique<EventBaseLoopController>());
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
}
TEST(FiberManager, batonWaitTimeoutMany) {
}
TEST(FiberManager, batonWaitTimeoutMany) {
- FiberManager manager(folly::make_unique<EventBaseLoopController>());
+ FiberManager manager(std::make_unique<EventBaseLoopController>());
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
}
TEST(FiberManager, remoteFutureTest) {
}
TEST(FiberManager, remoteFutureTest) {
- FiberManager fiberManager(folly::make_unique<SimpleLoopController>());
+ FiberManager fiberManager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
// Test that a void function produes a Future<Unit>.
TEST(FiberManager, remoteFutureVoidUnitTest) {
// Test that a void function produes a Future<Unit>.
TEST(FiberManager, remoteFutureVoidUnitTest) {
- FiberManager fiberManager(folly::make_unique<SimpleLoopController>());
+ FiberManager fiberManager(std::make_unique<SimpleLoopController>());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fiberManager.loopController());
auto task = [&sem, kTasks, kIterations, kNumTokens](
int& counter, folly::fibers::Baton& baton) {
auto task = [&sem, kTasks, kIterations, kNumTokens](
int& counter, folly::fibers::Baton& baton) {
- FiberManager manager(folly::make_unique<EventBaseLoopController>());
+ FiberManager manager(std::make_unique<EventBaseLoopController>());
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
folly::EventBase evb;
dynamic_cast<EventBaseLoopController&>(manager.loopController())
.attachEventBase(evb);
folly::ScopedEventBaseThread thread;
auto evb1 =
folly::ScopedEventBaseThread thread;
auto evb1 =
- folly::make_unique<folly::VirtualEventBase>(*thread.getEventBase());
+ std::make_unique<folly::VirtualEventBase>(*thread.getEventBase());
auto& evb2 = thread.getEventBase()->getVirtualEventBase();
getFiberManager(*evb1).addTaskRemote([&] {
auto& evb2 = thread.getEventBase()->getVirtualEventBase();
getFiberManager(*evb1).addTaskRemote([&] {
folly::fibers::FiberManager::Options opts;
opts.recordStackEvery = 1;
folly::fibers::FiberManager::Options opts;
opts.recordStackEvery = 1;
- FiberManager fm(folly::make_unique<SimpleLoopController>(), opts);
+ FiberManager fm(std::make_unique<SimpleLoopController>(), opts);
auto& loopController =
dynamic_cast<SimpleLoopController&>(fm.loopController());
auto& loopController =
dynamic_cast<SimpleLoopController&>(fm.loopController());
struct Application {
public:
Application()
struct Application {
public:
Application()
- : fiberManager(folly::make_unique<SimpleLoopController>()),
+ : fiberManager(std::make_unique<SimpleLoopController>()),
toSend(20),
maxOutstanding(5) {}
toSend(20),
maxOutstanding(5) {}
template <class F>
Future<Unit> times(const int n, F&& thunk) {
return folly::whileDo(
template <class F>
Future<Unit> times(const int n, F&& thunk) {
return folly::whileDo(
- [ n, count = folly::make_unique<std::atomic<int>>(0) ]() mutable {
+ [ n, count = std::make_unique<std::atomic<int>>(0) ]() mutable {
return count->fetch_add(1) < n;
},
std::forward<F>(thunk));
return count->fetch_add(1) < n;
},
std::forward<F>(thunk));
interruptLock_.lock();
}
if (!interrupt_ && !hasResult()) {
interruptLock_.lock();
}
if (!interrupt_ && !hasResult()) {
- interrupt_ = folly::make_unique<exception_wrapper>(std::move(e));
+ interrupt_ = std::make_unique<exception_wrapper>(std::move(e));
if (interruptHandler_) {
interruptHandler_(*interrupt_);
}
if (interruptHandler_) {
interruptHandler_(*interrupt_);
}
}
TEST(Filter, moveOnlyValue) {
}
TEST(Filter, moveOnlyValue) {
- EXPECT_EQ(42,
- *makeFuture(folly::make_unique<int>(42))
- .filter([](std::unique_ptr<int> const&) { return true; })
- .get());
+ EXPECT_EQ(
+ 42,
+ *makeFuture(std::make_unique<int>(42))
+ .filter([](std::unique_ptr<int> const&) { return true; })
+ .get());
// slow test so I won't do that but if it ever fails, take it seriously, and
// run the test binary with "--gtest_repeat=10000 --gtest_filter=*detachRace"
// (Don't forget to enable ASAN)
// slow test so I won't do that but if it ever fails, take it seriously, and
// run the test binary with "--gtest_repeat=10000 --gtest_filter=*detachRace"
// (Don't forget to enable ASAN)
- auto p = folly::make_unique<Promise<bool>>();
- auto f = folly::make_unique<Future<bool>>(p->getFuture());
+ auto p = std::make_unique<Promise<bool>>();
+ auto f = std::make_unique<Future<bool>>(p->getFuture());
folly::Baton<> baton;
std::thread t1([&]{
baton.post();
folly::Baton<> baton;
std::thread t1([&]{
baton.post();
{
folly::RequestContextScopeGuard rctx;
RequestContext::get()->setContextData(
{
folly::RequestContextScopeGuard rctx;
RequestContext::get()->setContextData(
- "key", folly::make_unique<MyRequestData>(true));
+ "key", std::make_unique<MyRequestData>(true));
auto checker = [](int lineno) {
return [lineno](Try<int>&& /* t */) {
auto d = static_cast<MyRequestData*>(
auto checker = [](int lineno) {
return [lineno](Try<int>&& /* t */) {
auto d = static_cast<MyRequestData*>(
TEST(NonCopyableLambda, unique_ptr) {
Promise<Unit> promise;
TEST(NonCopyableLambda, unique_ptr) {
Promise<Unit> promise;
- auto int_ptr = folly::make_unique<int>(1);
+ auto int_ptr = std::make_unique<int>(1);
}
TEST(Promise, brokenOnDelete) {
}
TEST(Promise, brokenOnDelete) {
- auto p = folly::make_unique<Promise<int>>();
+ auto p = std::make_unique<Promise<int>>();
auto f = p->getFuture();
EXPECT_FALSE(f.isReady());
auto f = p->getFuture();
EXPECT_FALSE(f.isReady());
}
TEST(Promise, brokenPromiseHasTypeInfo) {
}
TEST(Promise, brokenPromiseHasTypeInfo) {
- auto pInt = folly::make_unique<Promise<int>>();
+ auto pInt = std::make_unique<Promise<int>>();
auto fInt = pInt->getFuture();
auto fInt = pInt->getFuture();
- auto pFloat = folly::make_unique<Promise<float>>();
+ auto pFloat = std::make_unique<Promise<float>>();
auto fFloat = pFloat->getFuture();
pInt.reset();
auto fFloat = pFloat->getFuture();
pInt.reset();
TEST(Via, viaThenGetWasRacy) {
ThreadExecutor x;
TEST(Via, viaThenGetWasRacy) {
ThreadExecutor x;
- std::unique_ptr<int> val = folly::via(&x)
- .then([] { return folly::make_unique<int>(42); })
- .get();
+ std::unique_ptr<int> val =
+ folly::via(&x).then([] { return std::make_unique<int>(42); }).get();
ASSERT_TRUE(!!val);
EXPECT_EQ(42, *val);
}
ASSERT_TRUE(!!val);
EXPECT_EQ(42, *val);
}
TEST(ViaFunc, moveOnly) {
ManualExecutor x;
TEST(ViaFunc, moveOnly) {
ManualExecutor x;
- auto intp = folly::make_unique<int>(42);
+ auto intp = std::make_unique<int>(42);
EXPECT_EQ(42, via(&x, [intp = std::move(intp)] { return *intp; }).getVia(&x));
}
EXPECT_EQ(42, via(&x, [intp = std::move(intp)] { return *intp; }).getVia(&x));
}
EXPECT_EQ(4, o | unwrap);
EXPECT_THROW(e | unwrap, OptionalEmptyException);
EXPECT_EQ(4, o | unwrap);
EXPECT_THROW(e | unwrap, OptionalEmptyException);
- auto oup = folly::make_optional(folly::make_unique<int>(5));
+ auto oup = folly::make_optional(std::make_unique<int>(5));
// optional has a value, and that value is non-null
EXPECT_TRUE(bool(oup | unwrap));
EXPECT_EQ(5, *(oup | unwrap));
EXPECT_TRUE(oup.hasValue()); // still has a pointer (null or not)
EXPECT_TRUE(bool(oup.value())); // that value isn't null
// optional has a value, and that value is non-null
EXPECT_TRUE(bool(oup | unwrap));
EXPECT_EQ(5, *(oup | unwrap));
EXPECT_TRUE(oup.hasValue()); // still has a pointer (null or not)
EXPECT_TRUE(bool(oup.value())); // that value isn't null
- auto moved1 = std::move(oup) | unwrapOr(folly::make_unique<int>(6));
+ auto moved1 = std::move(oup) | unwrapOr(std::make_unique<int>(6));
// oup still has a value, but now it's now nullptr since the pointer was moved
// into moved1
EXPECT_TRUE(oup.hasValue());
// oup still has a value, but now it's now nullptr since the pointer was moved
// into moved1
EXPECT_TRUE(oup.hasValue());
EXPECT_TRUE(bool(moved1));
EXPECT_EQ(5, *moved1);
EXPECT_TRUE(bool(moved1));
EXPECT_EQ(5, *moved1);
- auto moved2 = std::move(oup) | unwrapOr(folly::make_unique<int>(7));
+ auto moved2 = std::move(oup) | unwrapOr(std::make_unique<int>(7));
// oup's still-valid nullptr value wins here, the pointer to 7 doesn't apply
EXPECT_FALSE(moved2);
oup.clear();
// oup's still-valid nullptr value wins here, the pointer to 7 doesn't apply
EXPECT_FALSE(moved2);
oup.clear();
- auto moved3 = std::move(oup) | unwrapOr(folly::make_unique<int>(8));
+ auto moved3 = std::move(oup) | unwrapOr(std::make_unique<int>(8));
// oup is empty now, so the unwrapOr comes into play.
EXPECT_TRUE(bool(moved3));
EXPECT_EQ(8, *moved3);
// oup is empty now, so the unwrapOr comes into play.
EXPECT_TRUE(bool(moved3));
EXPECT_EQ(8, *moved3);
{
auto opt = folly::make_optional(std::make_shared<int>(8));
{
auto opt = folly::make_optional(std::make_shared<int>(8));
- auto fallback = unwrapOr(folly::make_unique<int>(9));
+ auto fallback = unwrapOr(std::make_unique<int>(9));
// fallback must be std::move'd to be used
EXPECT_EQ(8, *(opt | std::move(fallback)));
EXPECT_TRUE(bool(opt.value())); // shared_ptr copied out, not moved
// fallback must be std::move'd to be used
EXPECT_EQ(8, *(opt | std::move(fallback)));
EXPECT_TRUE(bool(opt.value())); // shared_ptr copied out, not moved
<< "): client intitiated SSL renegotiation not permitted";
return ReadResult(
READ_ERROR,
<< "): client intitiated SSL renegotiation not permitted";
return ReadResult(
READ_ERROR,
- folly::make_unique<SSLException>(SSLError::CLIENT_RENEGOTIATION));
+ std::make_unique<SSLException>(SSLError::CLIENT_RENEGOTIATION));
}
if (bytes <= 0) {
int error = SSL_get_error(ssl_, bytes);
}
if (bytes <= 0) {
int error = SSL_get_error(ssl_, bytes);
<< "): unsupported SSL renegotiation during read";
return ReadResult(
READ_ERROR,
<< "): unsupported SSL renegotiation during read";
return ReadResult(
READ_ERROR,
- folly::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
+ std::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
} else {
if (zero_return(error, bytes)) {
return ReadResult(bytes);
} else {
if (zero_return(error, bytes)) {
return ReadResult(bytes);
<< "reason: " << ERR_reason_error_string(errError);
return ReadResult(
READ_ERROR,
<< "reason: " << ERR_reason_error_string(errError);
return ReadResult(
READ_ERROR,
- folly::make_unique<SSLException>(error, errError, bytes, errno));
+ std::make_unique<SSLException>(error, errError, bytes, errno));
}
} else {
appBytesReceived_ += bytes;
}
} else {
appBytesReceived_ += bytes;
<< "unsupported SSL renegotiation during write";
return WriteResult(
WRITE_ERROR,
<< "unsupported SSL renegotiation during write";
return WriteResult(
WRITE_ERROR,
- folly::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
+ std::make_unique<SSLException>(SSLError::INVALID_RENEGOTIATION));
} else {
if (zero_return(error, rc)) {
return WriteResult(0);
} else {
if (zero_return(error, rc)) {
return WriteResult(0);
<< ", reason: " << ERR_reason_error_string(errError);
return WriteResult(
WRITE_ERROR,
<< ", reason: " << ERR_reason_error_string(errError);
return WriteResult(
WRITE_ERROR,
- folly::make_unique<SSLException>(error, errError, rc, errno));
+ std::make_unique<SSLException>(error, errError, rc, errno));
<< "TODO: AsyncSSLSocket currently does not support calling "
<< "write() before the handshake has fully completed";
return WriteResult(
<< "TODO: AsyncSSLSocket currently does not support calling "
<< "write() before the handshake has fully completed";
return WriteResult(
- WRITE_ERROR, folly::make_unique<SSLException>(SSLError::EARLY_WRITE));
+ WRITE_ERROR, std::make_unique<SSLException>(SSLError::EARLY_WRITE));
}
// Declare a buffer used to hold small write requests. It could point to a
}
// Declare a buffer used to hold small write requests. It could point to a
registerForConnectEvents();
} catch (const AsyncSocketException& ex) {
return WriteResult(
registerForConnectEvents();
} catch (const AsyncSocketException& ex) {
return WriteResult(
- WRITE_ERROR, folly::make_unique<AsyncSocketException>(ex));
+ WRITE_ERROR, std::make_unique<AsyncSocketException>(ex));
}
// Let's fake it that no bytes were written and return an errno.
errno = EAGAIN;
}
// Let's fake it that no bytes were written and return an errno.
errno = EAGAIN;
totalWritten = -1;
} catch (const AsyncSocketException& ex) {
return WriteResult(
totalWritten = -1;
} catch (const AsyncSocketException& ex) {
return WriteResult(
- WRITE_ERROR, folly::make_unique<AsyncSocketException>(ex));
+ WRITE_ERROR, std::make_unique<AsyncSocketException>(ex));
}
} else if (errno == EAGAIN) {
// Normally sendmsg would indicate that the write would block.
}
} else if (errno == EAGAIN) {
// Normally sendmsg would indicate that the write would block.
// instead, and is an error condition indicating no fds available.
return WriteResult(
WRITE_ERROR,
// instead, and is an error condition indicating no fds available.
return WriteResult(
WRITE_ERROR,
- folly::make_unique<AsyncSocketException>(
+ std::make_unique<AsyncSocketException>(
AsyncSocketException::UNKNOWN, "No more free local ports"));
}
} else {
AsyncSocketException::UNKNOWN, "No more free local ports"));
}
} else {
VirtualEventBase& EventBase::getVirtualEventBase() {
folly::call_once(virtualEventBaseInitFlag_, [&] {
VirtualEventBase& EventBase::getVirtualEventBase() {
folly::call_once(virtualEventBaseInitFlag_, [&] {
- virtualEventBase_ = folly::make_unique<VirtualEventBase>(*this);
+ virtualEventBase_ = std::make_unique<VirtualEventBase>(*this);
});
return *virtualEventBase_;
});
return *virtualEventBase_;
if (count_ != 0) {
const uint64_t numElements = WHEEL_BUCKETS * WHEEL_SIZE;
auto maxBuckets = std::min(numElements, count_);
if (count_ != 0) {
const uint64_t numElements = WHEEL_BUCKETS * WHEEL_SIZE;
auto maxBuckets = std::min(numElements, count_);
- auto buckets = folly::make_unique<CallbackList[]>(maxBuckets);
+ auto buckets = std::make_unique<CallbackList[]>(maxBuckets);
size_t countBuckets = 0;
for (auto& tick : buckets_) {
for (auto& bucket : tick) {
size_t countBuckets = 0;
for (auto& tick : buckets_) {
for (auto& bucket : tick) {
};
TimeoutManager::TimeoutManager()
};
TimeoutManager::TimeoutManager()
- : cobTimeouts_(folly::make_unique<CobTimeouts>()) {}
+ : cobTimeouts_(std::make_unique<CobTimeouts>()) {}
void TimeoutManager::runAfterDelay(
Func cob,
void TimeoutManager::runAfterDelay(
Func cob,
- auto timeout = folly::make_unique<CobTimeouts::CobTimeout>(
- this, std::move(cob), internal);
+ auto timeout =
+ std::make_unique<CobTimeouts::CobTimeout>(this, std::move(cob), internal);
if (!timeout->scheduleTimeout(milliseconds)) {
return false;
}
if (!timeout->scheduleTimeout(milliseconds)) {
return false;
}
ReadEOFCallback readCallback(&writeCallback);
HandshakeCallback handshakeCallback(&readCallback);
SSLServerAcceptCallback acceptCallback(&handshakeCallback);
ReadEOFCallback readCallback(&writeCallback);
HandshakeCallback handshakeCallback(&readCallback);
SSLServerAcceptCallback acceptCallback(&handshakeCallback);
- auto server = folly::make_unique<TestSSLServer>(&acceptCallback);
+ auto server = std::make_unique<TestSSLServer>(&acceptCallback);
// Set up SSL context.
auto sslContext = std::make_shared<SSLContext>();
// Set up SSL context.
auto sslContext = std::make_shared<SSLContext>();
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], false));
AsyncSSLSocket::UniquePtr serverSock(
new AsyncSSLSocket(serverCtx, &eventBase, fds[1], true));
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], false));
AsyncSSLSocket::UniquePtr serverSock(
new AsyncSSLSocket(serverCtx, &eventBase, fds[1], true));
- client = folly::make_unique<NpnClient>(std::move(clientSock));
- server = folly::make_unique<NpnServer>(std::move(serverSock));
+ client = std::make_unique<NpnClient>(std::move(clientSock));
+ server = std::make_unique<NpnServer>(std::move(serverSock));
};
TEST(AsyncSocketTest, EvbCallbacks) {
};
TEST(AsyncSocketTest, EvbCallbacks) {
- auto cb = folly::make_unique<MockEvbChangeCallback>();
+ auto cb = std::make_unique<MockEvbChangeCallback>();
EventBase evb;
std::shared_ptr<AsyncSocket> socket = AsyncSocket::newSocket(&evb);
EventBase evb;
std::shared_ptr<AsyncSocket> socket = AsyncSocket::newSocket(&evb);
void start() {
CHECK(evb_->isInEventBaseThread());
void start() {
CHECK(evb_->isInEventBaseThread());
- socket_ = folly::make_unique<AsyncUDPServerSocket>(
- evb_,
- 1500);
+ socket_ = std::make_unique<AsyncUDPServerSocket>(evb_, 1500);
try {
socket_->bind(addr_);
try {
socket_->bind(addr_);
CHECK(evb_->isInEventBaseThread());
server_ = server;
CHECK(evb_->isInEventBaseThread());
server_ = server;
- socket_ = folly::make_unique<AsyncUDPSocket>(evb_);
+ socket_ = std::make_unique<AsyncUDPSocket>(evb_);
try {
socket_->bind(folly::SocketAddress("127.0.0.1", 0));
try {
socket_->bind(folly::SocketAddress("127.0.0.1", 0));
}
TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
}
TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
- std::unique_ptr<EventBase> evb = folly::make_unique<EventBase>();
+ std::unique_ptr<EventBase> evb = std::make_unique<EventBase>();
}
TEST(EventBaseTest, LoopKeepAliveShutdown) {
}
TEST(EventBaseTest, LoopKeepAliveShutdown) {
- auto evb = folly::make_unique<EventBase>();
+ auto evb = std::make_unique<EventBase>();
}
TEST(EventBaseTest, LoopKeepAliveAtomic) {
}
TEST(EventBaseTest, LoopKeepAliveAtomic) {
- auto evb = folly::make_unique<EventBase>();
+ auto evb = std::make_unique<EventBase>();
static constexpr size_t kNumThreads = 100;
static constexpr size_t kNumTasks = 100;
static constexpr size_t kNumThreads = 100;
static constexpr size_t kNumTasks = 100;
size_t done{0};
for (size_t i = 0; i < kNumThreads; ++i) {
size_t done{0};
for (size_t i = 0; i < kNumThreads; ++i) {
- batons.emplace_back(folly::make_unique<Baton<>>());
+ batons.emplace_back(std::make_unique<Baton<>>());
}
for (size_t i = 0; i < kNumThreads; ++i) {
}
for (size_t i = 0; i < kNumThreads; ++i) {
EXPECT_EQ(nullptr, RequestContext::get()->getContextData("test"));
EXPECT_EQ(nullptr, RequestContext::get()->getContextData("test"));
- RequestContext::get()->setContextData(
- "test", folly::make_unique<TestData>(10));
+ RequestContext::get()->setContextData("test", std::make_unique<TestData>(10));
base.runInEventBaseThread([&](){
EXPECT_TRUE(RequestContext::get() != nullptr);
auto data = dynamic_cast<TestData*>(
base.runInEventBaseThread([&](){
EXPECT_TRUE(RequestContext::get() != nullptr);
auto data = dynamic_cast<TestData*>(
TEST(RequestContext, setIfAbsentTest) {
EXPECT_TRUE(RequestContext::get() != nullptr);
TEST(RequestContext, setIfAbsentTest) {
EXPECT_TRUE(RequestContext::get() != nullptr);
- RequestContext::get()->setContextData(
- "test", folly::make_unique<TestData>(10));
+ RequestContext::get()->setContextData("test", std::make_unique<TestData>(10));
EXPECT_FALSE(RequestContext::get()->setContextDataIfAbsent(
EXPECT_FALSE(RequestContext::get()->setContextDataIfAbsent(
- "test", folly::make_unique<TestData>(20)));
+ "test", std::make_unique<TestData>(20)));
EXPECT_EQ(10,
dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test"))->data_);
EXPECT_TRUE(RequestContext::get()->setContextDataIfAbsent(
EXPECT_EQ(10,
dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test"))->data_);
EXPECT_TRUE(RequestContext::get()->setContextDataIfAbsent(
- "test2", folly::make_unique<TestData>(20)));
+ "test2", std::make_unique<TestData>(20)));
EXPECT_EQ(20,
dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test2"))->data_);
EXPECT_EQ(20,
dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test2"))->data_);
TEST(RequestContext, testSetUnset) {
RequestContext::create();
auto ctx1 = RequestContext::saveContext();
TEST(RequestContext, testSetUnset) {
RequestContext::create();
auto ctx1 = RequestContext::saveContext();
- ctx1->setContextData("test", folly::make_unique<TestData>(10));
+ ctx1->setContextData("test", std::make_unique<TestData>(10));
auto testData1 = dynamic_cast<TestData*>(ctx1->getContextData("test"));
// Override RequestContext
RequestContext::create();
auto ctx2 = RequestContext::saveContext();
auto testData1 = dynamic_cast<TestData*>(ctx1->getContextData("test"));
// Override RequestContext
RequestContext::create();
auto ctx2 = RequestContext::saveContext();
- ctx2->setContextData("test", folly::make_unique<TestData>(20));
+ ctx2->setContextData("test", std::make_unique<TestData>(20));
auto testData2 = dynamic_cast<TestData*>(ctx2->getContextData("test"));
// Check ctx1->onUnset was called
auto testData2 = dynamic_cast<TestData*>(ctx2->getContextData("test"));
// Check ctx1->onUnset was called
virtual ~DeadlockTestData() {
RequestContext::get()->setContextData(
virtual ~DeadlockTestData() {
RequestContext::get()->setContextData(
- val_, folly::make_unique<TestData>(1));
+ val_, std::make_unique<TestData>(1));
}
void onSet() override {}
}
void onSet() override {}
};
RequestContext::get()->setContextData(
};
RequestContext::get()->setContextData(
- "test", folly::make_unique<DeadlockTestData>("test2"));
+ "test", std::make_unique<DeadlockTestData>("test2"));
RequestContext::get()->clearContextData("test");
}
RequestContext::get()->clearContextData("test");
}
ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess =
ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess =
- folly::make_unique<SSLSession>(clientPtr->getSSLSession());
+ std::make_unique<SSLSession>(clientPtr->getSSLSession());
sessiondata = sess->serialize();
ASSERT_TRUE(!sessiondata.empty());
}
sessiondata = sess->serialize();
ASSERT_TRUE(!sessiondata.empty());
}
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], serverName));
auto clientPtr = clientSock.get();
std::unique_ptr<SSLSession> sess =
new AsyncSSLSocket(clientCtx, &eventBase, fds[0], serverName));
auto clientPtr = clientSock.get();
std::unique_ptr<SSLSession> sess =
- folly::make_unique<SSLSession>(sessiondata);
+ std::make_unique<SSLSession>(sessiondata);
ASSERT_NE(sess.get(), nullptr);
clientSock->setSSLSession(sess->getRawSSLSessionDangerous(), true);
AsyncSSLSocket::UniquePtr serverSock(
ASSERT_NE(sess.get(), nullptr);
clientSock->setSSLSession(sess->getRawSSLSessionDangerous(), true);
AsyncSSLSocket::UniquePtr serverSock(
ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess =
ASSERT_TRUE(client.handshakeSuccess_);
std::unique_ptr<SSLSession> sess =
- folly::make_unique<SSLSession>(clientPtr->getSSLSession());
+ std::make_unique<SSLSession>(clientPtr->getSSLSession());
ASSERT_NE(sess, nullptr);
auto sessID = sess->getSessionID();
ASSERT_GE(sessID.length(), 0);
ASSERT_NE(sess, nullptr);
auto sessID = sess->getSessionID();
ASSERT_GE(sessID.length(), 0);
namespace folly {
ScopedBoundPort::ScopedBoundPort(IPAddress host) {
namespace folly {
ScopedBoundPort::ScopedBoundPort(IPAddress host) {
- ebth_ = folly::make_unique<ScopedEventBaseThread>();
+ ebth_ = std::make_unique<ScopedEventBaseThread>();
ebth_->getEventBase()->runInEventBaseThreadAndWait([&] {
sock_ = AsyncServerSocket::newSocket(ebth_->getEventBase());
sock_->bind(SocketAddress(host, 0));
ebth_->getEventBase()->runInEventBaseThreadAndWait([&] {
sock_ = AsyncServerSocket::newSocket(ebth_->getEventBase());
sock_->bind(SocketAddress(host, 0));
public:
// Holds and takes ownership of an SSL_SESSION object by incrementing refcount
explicit SSLSession(SSL_SESSION* session, bool takeOwnership = true)
public:
// Holds and takes ownership of an SSL_SESSION object by incrementing refcount
explicit SSLSession(SSL_SESSION* session, bool takeOwnership = true)
- : impl_(folly::make_unique<detail::SSLSessionImpl>(
- session,
- takeOwnership)) {}
+ : impl_(
+ std::make_unique<detail::SSLSessionImpl>(session, takeOwnership)) {}
// Deserialize from a string
explicit SSLSession(const std::string& serializedSession)
// Deserialize from a string
explicit SSLSession(const std::string& serializedSession)
- : impl_(folly::make_unique<detail::SSLSessionImpl>(serializedSession)) {}
+ : impl_(std::make_unique<detail::SSLSessionImpl>(serializedSession)) {}
// Serialize to a string that is suitable to store in a persistent cache
std::string serialize() const {
// Serialize to a string that is suitable to store in a persistent cache
std::string serialize() const {
typedef folly::AtomicHashMap<int,std::shared_ptr<MyObject>> MyMap;
typedef std::lock_guard<std::mutex> Guard;
typedef folly::AtomicHashMap<int,std::shared_ptr<MyObject>> MyMap;
typedef std::lock_guard<std::mutex> Guard;
-std::unique_ptr<MyMap> newMap() { return folly::make_unique<MyMap>(100); }
+std::unique_ptr<MyMap> newMap() { return std::make_unique<MyMap>(100); }
struct MyObjectDirectory {
MyObjectDirectory()
struct MyObjectDirectory {
MyObjectDirectory()
// NonCopyableLambda
TEST(Function, NonCopyableLambda) {
// NonCopyableLambda
TEST(Function, NonCopyableLambda) {
- auto unique_ptr_int = folly::make_unique<int>(900);
+ auto unique_ptr_int = std::make_unique<int>(900);
EXPECT_EQ(900, *unique_ptr_int);
struct {
EXPECT_EQ(900, *unique_ptr_int);
struct {
runElementTypeTest(std::make_pair(10, string("def")));
runElementTypeTest(vector<string>{{"abc"}});
runElementTypeTest(std::make_shared<char>('a'));
runElementTypeTest(std::make_pair(10, string("def")));
runElementTypeTest(vector<string>{{"abc"}});
runElementTypeTest(std::make_shared<char>('a'));
- runElementTypeTest(folly::make_unique<char>('a'));
+ runElementTypeTest(std::make_unique<char>('a'));
runElementTypeTest(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0);
}
runElementTypeTest(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0);
}
runElementTypeTest<true>(std::make_pair(10, string("def")));
runElementTypeTest<true>(vector<string>{{"abc"}});
runElementTypeTest<true>(std::make_shared<char>('a'));
runElementTypeTest<true>(std::make_pair(10, string("def")));
runElementTypeTest<true>(vector<string>{{"abc"}});
runElementTypeTest<true>(std::make_shared<char>('a'));
- runElementTypeTest<true>(folly::make_unique<char>('a'));
+ runElementTypeTest<true>(std::make_unique<char>('a'));
runElementTypeTest<true>(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0);
}
runElementTypeTest<true>(boost::intrusive_ptr<RefCounted>(new RefCounted));
EXPECT_EQ(RefCounted::active_instances, 0);
}
Widget::totalVal_ = 0;
{
ThreadLocalPtr<Widget> w;
Widget::totalVal_ = 0;
{
ThreadLocalPtr<Widget> w;
- auto source = folly::make_unique<Widget>();
+ auto source = std::make_unique<Widget>();
std::thread([&w, &source]() {
w.reset(std::move(source));
w.get()->val_ += 10;
std::thread([&w, &source]() {
w.reset(std::move(source));
w.get()->val_ += 10;
TEST(Try, makeTryWith) {
auto func = []() {
TEST(Try, makeTryWith) {
auto func = []() {
- return folly::make_unique<int>(1);
+ return std::make_unique<int>(1);
};
auto result = makeTryWith(func);
};
auto result = makeTryWith(func);