Henry Robinson has uploaded a new change for review. http://gerrit.cloudera.org:8080/6442
Change subject: Allow BlockingQueue and ThreadPool to accept rvalue args ...................................................................... Allow BlockingQueue and ThreadPool to accept rvalue args Previously the BlockingQueue and ThreadPool APIs only accepted const lvalue references, so the argument was always copied into the queue. Very often we create a thin wrapper for each work item we submit to a thread pool, and will not want to use that object again, so moving it into the pool rather than copying makes the most sense. Note the introduction of an extra template parameter into Offer() and BlockingPut*(). To enable perfect-forwarding (i.e. allow the methods to accept rvalue or lvalues and pass them through), we need to use a) rvalue references (V&&) and b) do so in a 'type-deducing context' [1]. Having the enclosing class be template-parameterized does not count as type-deducing, so we add the dummy V parameter and the compiler will ensure that V is properly compatible with the original T type. [1] http://eli.thegreenplace.net/2014/perfect-forwarding-and-universal-references-in-c/ Change-Id: I1791870576cb269e86495034f92555de48f92f10 --- M be/src/rpc/TAcceptQueueServer.cpp M be/src/util/blocking-queue.h M be/src/util/thread-pool.h 3 files changed, 15 insertions(+), 7 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/42/6442/1 -- To view, visit http://gerrit.cloudera.org:8080/6442 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1791870576cb269e86495034f92555de48f92f10 Gerrit-PatchSet: 1 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Henry Robinson <[email protected]>
