remove MoveWrapper from io/async/AsyncUDPServerSocket.h
authorSven Over <over@fb.com>
Sat, 16 Apr 2016 03:26:30 +0000 (20:26 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Sat, 16 Apr 2016 03:35:19 +0000 (20:35 -0700)
Summary:This is the last place in folly that uses MoveWrapper (other than
the MoveWrapper implementation itself and its tests, of course).

Instead of using a MoveWrapper, the object in question is moved
into the lambda using C++14 syntax, and the lambda is moved in a
call to EventBase::runInEventBaseThread which is possible now
that the EventBase methods accept non-copyable callbacks.

Reviewed By: yfeldblum

Differential Revision: D3169316

fb-gh-sync-id: 2dcb1a523ac417f4619c607898e58b572648e3da
fbshipit-source-id: 2dcb1a523ac417f4619c607898e58b572648e3da

folly/io/async/AsyncUDPServerSocket.h

index ec1331cbdd2b04b2bd0184701f4086cefcc18944..899f75d379451ea78678264e3f7a01d2103f2d0d 100644 (file)
@@ -16,7 +16,6 @@
 
 #pragma once
 
-#include <folly/MoveWrapper.h>
 #include <folly/io/IOBufQueue.h>
 #include <folly/Memory.h>
 #include <folly/io/async/AsyncUDPSocket.h>
@@ -165,18 +164,21 @@ class AsyncUDPServerSocket : private AsyncUDPSocket::ReadCallback
 
     auto client = clientAddress;
     auto callback = listeners_[nextListener_].second;
-    auto mvp =
-        folly::MoveWrapper<
-            std::unique_ptr<folly::IOBuf>>(std::move(data));
     auto socket = socket_;
 
     // Schedule it in the listener's eventbase
     // XXX: Speed this up
-    std::function<void()> f = [socket, client, callback, mvp, truncated] () mutable {
-      callback->onDataAvailable(socket, client, std::move(*mvp), truncated);
+    auto f = [
+      socket,
+      client,
+      callback,
+      data = std::move(data),
+      truncated
+    ]() mutable {
+      callback->onDataAvailable(socket, client, std::move(data), truncated);
     };
 
-    listeners_[nextListener_].first->runInEventBaseThread(f);
+    listeners_[nextListener_].first->runInEventBaseThread(std::move(f));
     ++nextListener_;
   }