Commit f34acf2c authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Codemod folly::make_unique to std::make_unique

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
parent fea92be9
......@@ -54,7 +54,7 @@ class AtomicLinkedList {
* 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());
}
......
......@@ -41,7 +41,7 @@ Try<T>::Try(typename std::enable_if<std::is_same<Unit, T2>::value,
} 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()));
}
}
......@@ -71,7 +71,7 @@ Try<T>::Try(const Try<T>& t) {
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_));
}
}
......@@ -86,7 +86,7 @@ Try<T>& Try<T>::operator=(const Try<T>& t) {
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_));
}
return *this;
}
......
......@@ -93,8 +93,8 @@ class Try {
* @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))) {}
/*
* DEPRECATED
......@@ -108,9 +108,9 @@ class Try {
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);
} catch (...) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception());
e_ = std::make_unique<exception_wrapper>(std::current_exception());
}
}
......@@ -266,8 +266,8 @@ class Try<void> {
* @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))) {}
/*
* DEPRECATED
......@@ -280,9 +280,9 @@ class Try<void> {
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);
} catch (...) {
e_ = folly::make_unique<exception_wrapper>(std::current_exception());
e_ = std::make_unique<exception_wrapper>(std::current_exception());
}
}
......@@ -290,7 +290,7 @@ class Try<void> {
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_);
}
return *this;
}
......
......@@ -102,7 +102,7 @@ TemporaryDirectory::TemporaryDirectory(
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());
}
......
......@@ -23,7 +23,7 @@ struct FutureDAGTest : public testing::Test {
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;
......
......@@ -29,7 +29,7 @@ template <template<typename> class MainPtr,
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;
......
......@@ -84,12 +84,12 @@ TEST_F(ReadMostlySharedPtrTest, BasicStores) {
// 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};
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());
......@@ -109,13 +109,13 @@ TEST_F(ReadMostlySharedPtrTest, BasicLoads) {
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);
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());
......@@ -174,18 +174,18 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) {
loads[0].requestAndWait();
ptr.reset(folly::make_unique<TestObject>(1, cnt));
ptr.reset(std::make_unique<TestObject>(1, cnt));
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();
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();
ptr.reset(folly::make_unique<TestObject>(5, cnt));
ptr.reset(std::make_unique<TestObject>(5, cnt));
loads[5].requestAndWait();
loads[6].requestAndWait();
......@@ -201,8 +201,7 @@ TEST_F(ReadMostlySharedPtrTest, LoadsFromThreads) {
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);
}
......@@ -217,7 +216,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
ReadMostlyMainPtr<TestObject> ptr;
// Store 1.
ptr.reset(folly::make_unique<TestObject>(1, cnt1));
ptr.reset(std::make_unique<TestObject>(1, cnt1));
Coordinator c;
......@@ -232,7 +231,7 @@ TEST_F(ReadMostlySharedPtrTest, ClearingCache) {
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.
......
......@@ -118,7 +118,7 @@ TEST(TemporaryDirectory, SafelyMove) {
expectTempdirExists(d);
expectTempdirExists(d2);
dir = folly::make_unique<TemporaryDirectory>(std::move(d));
dir = std::make_unique<TemporaryDirectory>(std::move(d));
dir2 = std::move(d2);
}
......
......@@ -335,7 +335,7 @@ class ScopedAlternateSignalStack {
return;
}
stack_ = folly::make_unique<AltStackBuffer>();
stack_ = std::make_unique<AltStackBuffer>();
setAlternateStack(stack_->data(), stack_->size());
}
......
......@@ -313,10 +313,10 @@ void FiberManager::addTaskRemote(F&& func) {
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_);
}
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());
......
......@@ -337,7 +337,7 @@ class FiberManager : public ::folly::Executor {
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;
......
......@@ -245,7 +245,7 @@ class CacheManager {
std::lock_guard<folly::SpinLock> lg(lock_);
if (inUse_ < kMaxInUse) {
++inUse_;
return folly::make_unique<StackCacheEntry>(stackSize);
return std::make_unique<StackCacheEntry>(stackSize);
}
return nullptr;
......@@ -277,7 +277,7 @@ class CacheManager {
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_;
......
......@@ -33,7 +33,7 @@ intptr_t TimeoutController::registerTimeout(
}
timeoutHandleBuckets_.emplace_back(
duration, folly::make_unique<TimeoutHandleList>());
duration, std::make_unique<TimeoutHandleList>());
return *timeoutHandleBuckets_.back().second;
}();
......
......@@ -31,7 +31,7 @@ static size_t sNumAwaits;
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());
......@@ -87,7 +87,7 @@ BENCHMARK(FiberManagerAllocateDeallocatePattern, iters) {
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());
......@@ -110,7 +110,7 @@ BENCHMARK(FiberManagerAllocateLargeChunk, iters) {
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());
......
This diff is collapsed.
......@@ -26,7 +26,7 @@ using namespace folly::fibers;
struct Application {
public:
Application()
: fiberManager(folly::make_unique<SimpleLoopController>()),
: fiberManager(std::make_unique<SimpleLoopController>()),
toSend(20),
maxOutstanding(5) {}
......
......@@ -1190,7 +1190,7 @@ Future<Unit> whileDo(P&& predicate, F&& thunk) {
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));
......
......@@ -240,7 +240,7 @@ class Core final {
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_);
}
......
......@@ -29,8 +29,9 @@ TEST(Filter, alwaysFalse) {
}
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());
}
......@@ -722,8 +722,8 @@ TEST(Future, detachRace) {
// 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();
......@@ -818,7 +818,7 @@ TEST(Future, RequestContext) {
{
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*>(
......
......@@ -38,7 +38,7 @@ TEST(NonCopyableLambda, basic) {
TEST(NonCopyableLambda, unique_ptr) {
Promise<Unit> promise;
auto int_ptr = folly::make_unique<int>(1);
auto int_ptr = std::make_unique<int>(1);
EXPECT_EQ(*int_ptr, 1);
......
......@@ -134,7 +134,7 @@ TEST(Promise, isFulfilledWithFuture) {
}
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());
......@@ -149,10 +149,10 @@ TEST(Promise, brokenOnDelete) {
}
TEST(Promise, brokenPromiseHasTypeInfo) {
auto pInt = folly::make_unique<Promise<int>>();
auto pInt = std::make_unique<Promise<int>>();
auto fInt = pInt->getFuture();
auto pFloat = folly::make_unique<Promise<float>>();
auto pFloat = std::make_unique<Promise<float>>();
auto fFloat = pFloat->getFuture();
pInt.reset();
......
......@@ -335,9 +335,8 @@ class ThreadExecutor : public Executor {
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);
}
......@@ -603,7 +602,7 @@ TEST(ViaFunc, isSticky) {
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));
}
......@@ -1274,14 +1274,14 @@ TEST(Gen, Unwrap) {
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
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());
......@@ -1289,12 +1289,12 @@ TEST(Gen, Unwrap) {
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();
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);
......@@ -1332,7 +1332,7 @@ TEST(Gen, Unwrap) {
{
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
......
......@@ -1338,7 +1338,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "): 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);
......@@ -1358,7 +1358,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "): 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);
......@@ -1375,7 +1375,7 @@ AsyncSSLSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
<< "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;
......@@ -1418,7 +1418,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int 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);
......@@ -1431,7 +1431,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::interpretSSLError(int rc, int 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));
}
}
......@@ -1452,7 +1452,7 @@ AsyncSocket::WriteResult AsyncSSLSocket::performWrite(
<< "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
......
......@@ -2011,7 +2011,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
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;
......@@ -2034,7 +2034,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
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.
......@@ -2043,7 +2043,7 @@ AsyncSocket::sendSocketMessage(int fd, struct msghdr* msg, int msg_flags) {
// 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 {
......
......@@ -740,7 +740,7 @@ const char* EventBase::getLibeventMethod() { return event_get_method(); }
VirtualEventBase& EventBase::getVirtualEventBase() {
folly::call_once(virtualEventBaseInitFlag_, [&] {
virtualEventBase_ = folly::make_unique<VirtualEventBase>(*this);
virtualEventBase_ = std::make_unique<VirtualEventBase>(*this);
});
return *virtualEventBase_;
......
......@@ -251,7 +251,7 @@ size_t HHWheelTimer::cancelAll() {
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) {
......
......@@ -72,7 +72,7 @@ struct TimeoutManager::CobTimeouts {
};
TimeoutManager::TimeoutManager()
: cobTimeouts_(folly::make_unique<CobTimeouts>()) {}
: cobTimeouts_(std::make_unique<CobTimeouts>()) {}
void TimeoutManager::runAfterDelay(
Func cob,
......@@ -92,8 +92,8 @@ bool TimeoutManager::tryRunAfterDelay(
return false;
}
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;
}
......
......@@ -181,7 +181,7 @@ TEST(AsyncSSLSocketTest, ReadAfterClose) {
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>();
......@@ -402,8 +402,8 @@ class NextProtocolTest : public testing::TestWithParam<NextProtocolTypePair> {
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));
eventBase.loop();
}
......
......@@ -2806,7 +2806,7 @@ class MockEvbChangeCallback : public AsyncSocket::EvbChangeCallback {
};
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);
......
......@@ -85,9 +85,7 @@ class UDPServer {
void start() {
CHECK(evb_->isInEventBaseThread());
socket_ = folly::make_unique<AsyncUDPServerSocket>(
evb_,
1500);
socket_ = std::make_unique<AsyncUDPServerSocket>(evb_, 1500);
try {
socket_->bind(addr_);
......@@ -159,7 +157,7 @@ class UDPClient
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));
......
......@@ -1789,7 +1789,7 @@ TEST(EventBaseTest, LoopKeepAliveInLoop) {
}
TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
std::unique_ptr<EventBase> evb = folly::make_unique<EventBase>();
std::unique_ptr<EventBase> evb = std::make_unique<EventBase>();
bool done = false;
......@@ -1817,7 +1817,7 @@ TEST(EventBaseTest, LoopKeepAliveWithLoopForever) {
}
TEST(EventBaseTest, LoopKeepAliveShutdown) {
auto evb = folly::make_unique<EventBase>();
auto evb = std::make_unique<EventBase>();
bool done = false;
......@@ -1840,7 +1840,7 @@ TEST(EventBaseTest, LoopKeepAliveShutdown) {
}
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;
......@@ -1850,7 +1850,7 @@ TEST(EventBaseTest, LoopKeepAliveAtomic) {
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) {
......
......@@ -56,8 +56,7 @@ TEST(RequestContext, SimpleTest) {
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*>(
......@@ -83,16 +82,15 @@ TEST(RequestContext, SimpleTest) {
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(
"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(
"test2", folly::make_unique<TestData>(20)));
"test2", std::make_unique<TestData>(20)));
EXPECT_EQ(20,
dynamic_cast<TestData*>(
RequestContext::get()->getContextData("test2"))->data_);
......@@ -104,13 +102,13 @@ TEST(RequestContext, setIfAbsentTest) {
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();
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
......@@ -137,7 +135,7 @@ TEST(RequestContext, deadlockTest) {
virtual ~DeadlockTestData() {
RequestContext::get()->setContextData(
val_, folly::make_unique<TestData>(1));
val_, std::make_unique<TestData>(1));
}
void onSet() override {}
......@@ -148,6 +146,6 @@ TEST(RequestContext, deadlockTest) {
};
RequestContext::get()->setContextData(
"test", folly::make_unique<DeadlockTestData>("test2"));
"test", std::make_unique<DeadlockTestData>("test2"));
RequestContext::get()->clearContextData("test");
}
......@@ -138,7 +138,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) {
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());
}
......@@ -150,7 +150,7 @@ TEST_F(SSLSessionTest, SerializeDeserializeTest) {
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(
......@@ -181,7 +181,7 @@ TEST_F(SSLSessionTest, GetSessionID) {
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);
......
......@@ -23,7 +23,7 @@
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));
......
......@@ -27,13 +27,12 @@ class SSLSession {
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)
: 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 {
......
......@@ -33,7 +33,7 @@ struct MyObject {
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()
......
......@@ -313,7 +313,7 @@ TEST(Function, Bind) {
// 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 {
......
......@@ -149,7 +149,7 @@ TEST(MPMCQueue, lots_of_element_types) {
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);
}
......@@ -160,7 +160,7 @@ TEST(MPMCQueue, lots_of_element_types_dynamic) {
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);
}
......
......@@ -103,7 +103,7 @@ TEST(ThreadLocalPtr, DefaultDeleterOwnershipTransfer) {
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;
......
......@@ -55,7 +55,7 @@ TEST(Try, moveOnly) {
TEST(Try, makeTryWith) {
auto func = []() {
return folly::make_unique<int>(1);
return std::make_unique<int>(1);
};
auto result = makeTryWith(func);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment