You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2025/05/02 17:55:28 UTC
(impala) branch master updated: IMPALA-13978: Remove gutil's gscoped_ptr/bind/callback functionality
This is an automated email from the ASF dual-hosted git repository.
joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 47913c10e IMPALA-13978: Remove gutil's gscoped_ptr/bind/callback functionality
47913c10e is described below
commit 47913c10e8f49d0eb9a532108cd55ea6dbc69ee3
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Sun Apr 20 14:59:27 2025 -0700
IMPALA-13978: Remove gutil's gscoped_ptr/bind/callback functionality
gutil's gscoped_ptr/bind/callback provide functionality that
was introduced in C++11. It has been obsolete for a long time
and is barely used in the codebase. Kudu removed this code from
their gutils quite a while ago:
https://github.com/apache/kudu/commit/4f7b1aaf88
This replaces gscoped_ptr/gscoped_array with std::unique_ptr
(matching Kudu's modifications for gutil). This removes gutil's
bind/callback/move, as they are now unused.
Testing:
- Ran precommit
Change-Id: I2ec79f32fb281f2bceeaed3e2fcbc75ae75308bd
Reviewed-on: http://gerrit.cloudera.org:8080/22821
Tested-by: Impala Public Jenkins <im...@cloudera.com>
Reviewed-by: Michael Smith <mi...@cloudera.com>
---
be/src/exec/kudu/kudu-scan-node.cc | 1 -
be/src/exec/kudu/kudu-scan-node.h | 1 -
be/src/exec/kudu/kudu-scanner.cc | 1 -
be/src/exec/kudu/kudu-table-sink.cc | 1 -
be/src/gutil/CMakeLists.txt | 1 -
be/src/gutil/bind.h | 539 ------
be/src/gutil/bind.h.pump | 153 --
be/src/gutil/bind_helpers.h | 551 ------
be/src/gutil/bind_internal.h | 2695 --------------------------
be/src/gutil/bind_internal.h.pump | 464 -----
be/src/gutil/callback.h | 765 --------
be/src/gutil/callback.h.pump | 436 -----
be/src/gutil/callback_forward.h | 17 -
be/src/gutil/callback_internal.cc | 36 -
be/src/gutil/callback_internal.h | 177 --
be/src/gutil/gscoped_ptr.h | 830 --------
be/src/gutil/move.h | 218 ---
be/src/gutil/stl_util.h | 26 -
be/src/gutil/strings/escaping.cc | 18 +-
be/src/gutil/strings/join.cc | 7 +-
be/src/gutil/strings/strcat.cc | 1 -
be/src/rpc/impala-service-pool.cc | 1 -
be/src/rpc/impala-service-pool.h | 1 -
be/src/runtime/buffered-tuple-stream-test.cc | 30 +-
be/src/util/hdr-histogram.h | 5 +-
25 files changed, 36 insertions(+), 6939 deletions(-)
diff --git a/be/src/exec/kudu/kudu-scan-node.cc b/be/src/exec/kudu/kudu-scan-node.cc
index 9c18da8fd..9e8350003 100644
--- a/be/src/exec/kudu/kudu-scan-node.cc
+++ b/be/src/exec/kudu/kudu-scan-node.cc
@@ -23,7 +23,6 @@
#include "exec/kudu/kudu-scanner.h"
#include "exec/kudu/kudu-util.h"
#include "exprs/scalar-expr.h"
-#include "gutil/gscoped_ptr.h"
#include "runtime/blocking-row-batch-queue.h"
#include "runtime/fragment-instance-state.h"
#include "runtime/mem-pool.h"
diff --git a/be/src/exec/kudu/kudu-scan-node.h b/be/src/exec/kudu/kudu-scan-node.h
index 9ef695923..3db0585c0 100644
--- a/be/src/exec/kudu/kudu-scan-node.h
+++ b/be/src/exec/kudu/kudu-scan-node.h
@@ -23,7 +23,6 @@
#include "common/atomic.h"
#include "exec/kudu/kudu-scan-node-base.h"
-#include "gutil/gscoped_ptr.h"
namespace impala {
diff --git a/be/src/exec/kudu/kudu-scanner.cc b/be/src/exec/kudu/kudu-scanner.cc
index 0a4a4e374..a7f24b872 100644
--- a/be/src/exec/kudu/kudu-scanner.cc
+++ b/be/src/exec/kudu/kudu-scanner.cc
@@ -32,7 +32,6 @@
#include "exprs/scalar-expr-evaluator.h"
#include "exprs/scalar-expr.h"
#include "exprs/slot-ref.h"
-#include "gutil/gscoped_ptr.h"
#include "gutil/strings/substitute.h"
#include "kudu/util/block_bloom_filter.h"
#include "kudu/util/logging.h"
diff --git a/be/src/exec/kudu/kudu-table-sink.cc b/be/src/exec/kudu/kudu-table-sink.cc
index d65cc40e1..69829710d 100644
--- a/be/src/exec/kudu/kudu-table-sink.cc
+++ b/be/src/exec/kudu/kudu-table-sink.cc
@@ -29,7 +29,6 @@
#include "exprs/scalar-expr-evaluator.h"
#include "exprs/scalar-expr.h"
#include "gen-cpp/ImpalaInternalService_constants.h"
-#include "gutil/gscoped_ptr.h"
#include "runtime/descriptors.h"
#include "runtime/exec-env.h"
#include "runtime/mem-tracker.h"
diff --git a/be/src/gutil/CMakeLists.txt b/be/src/gutil/CMakeLists.txt
index 7e12e84cb..95d70d0f9 100644
--- a/be/src/gutil/CMakeLists.txt
+++ b/be/src/gutil/CMakeLists.txt
@@ -19,7 +19,6 @@ INCLUDE_DIRECTORIES(${GLOG_INCLUDE_DIR})
set(GUTIL_SRCS
bits.cc
- callback_internal.cc
cpu.cc
dynamic_annotations.c
hash/city.cc
diff --git a/be/src/gutil/bind.h b/be/src/gutil/bind.h
deleted file mode 100644
index 534f208eb..000000000
--- a/be/src/gutil/bind.h
+++ /dev/null
@@ -1,539 +0,0 @@
-// This file was GENERATED by command:
-// pump.py bind.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_BIND_H_
-#define GUTIL_BIND_H_
-
-#include "gutil/bind_internal.h"
-#include "gutil/callback_internal.h"
-
-// -----------------------------------------------------------------------------
-// Usage documentation
-// -----------------------------------------------------------------------------
-//
-// See kudu/gutil/callback.h for documentation.
-//
-//
-// -----------------------------------------------------------------------------
-// Implementation notes
-// -----------------------------------------------------------------------------
-//
-// If you're reading the implementation, before proceeding further, you should
-// read the top comment of kudu/gutil/bind_internal.h for a definition of common
-// terms and concepts.
-//
-// RETURN TYPES
-//
-// Though Bind()'s result is meant to be stored in a Callback<> type, it
-// cannot actually return the exact type without requiring a large amount
-// of extra template specializations. The problem is that in order to
-// discern the correct specialization of Callback<>, Bind would need to
-// unwrap the function signature to determine the signature's arity, and
-// whether or not it is a method.
-//
-// Each unique combination of (arity, function_type, num_prebound) where
-// function_type is one of {function, method, const_method} would require
-// one specialization. We eventually have to do a similar number of
-// specializations anyways in the implementation (see the Invoker<>,
-// classes). However, it is avoidable in Bind if we return the result
-// via an indirection like we do below.
-//
-// TODO(ajwong): We might be able to avoid this now, but need to test.
-//
-// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>,
-// but it feels a little nicer to have the asserts here so people do not
-// need to crack open bind_internal.h. On the other hand, it makes Bind()
-// harder to read.
-
-namespace kudu {
-
-template <typename Functor>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void()>
- ::UnboundRunType>
-Bind(Functor functor) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- typedef internal::BindState<RunnableType, RunType, void()> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor)));
-}
-
-template <typename Functor, typename P1>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1));
-}
-
-template <typename Functor, typename P1, typename P2>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2));
-}
-
-template <typename Functor, typename P1, typename P2, typename P3>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A3Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
- p3_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2, p3));
-}
-
-template <typename Functor, typename P1, typename P2, typename P3, typename P4>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A3Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A4Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
- p3_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
- p4_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4));
-}
-
-template <typename Functor, typename P1, typename P2, typename P3, typename P4,
- typename P5>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
- const P5& p5) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A3Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A4Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A5Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
- p3_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
- p4_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
- p5_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5));
-}
-
-template <typename Functor, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType,
- typename internal::CallbackParamTraits<P6>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
- const P5& p5, const P6& p6) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A3Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A4Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A5Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A6Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
- p3_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
- p4_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
- p5_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
- p6_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType,
- typename internal::CallbackParamTraits<P6>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6));
-}
-
-template <typename Functor, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType,
- typename internal::CallbackParamTraits<P6>::StorageType,
- typename internal::CallbackParamTraits<P7>::StorageType)>
- ::UnboundRunType>
-Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
- const P5& p5, const P6& p6, const P7& p7) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !(base::is_non_const_reference<typename
- BoundFunctorTraits::A1Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A2Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A3Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A4Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A5Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A6Type>::value ||
- base::is_non_const_reference<typename
- BoundFunctorTraits::A7Type>::value ),
- do_not_bind_functions_with_nonconst_ref);
-
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
- p1_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P1>::value,
- first_bound_argument_to_method_cannot_be_array);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
- p2_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
- p3_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
- p4_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
- p5_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
- p6_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P7>::value,
- p7_is_refcounted_type_and_needs_scoped_refptr);
- typedef internal::BindState<RunnableType, RunType,
- void(typename internal::CallbackParamTraits<P1>::StorageType,
- typename internal::CallbackParamTraits<P2>::StorageType,
- typename internal::CallbackParamTraits<P3>::StorageType,
- typename internal::CallbackParamTraits<P4>::StorageType,
- typename internal::CallbackParamTraits<P5>::StorageType,
- typename internal::CallbackParamTraits<P6>::StorageType,
- typename internal::CallbackParamTraits<P7>::StorageType)> BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6,
- p7));
-}
-
-} // namespace kudu
-
-#endif // GUTIL_BIND_H_
diff --git a/be/src/gutil/bind.h.pump b/be/src/gutil/bind.h.pump
deleted file mode 100644
index 538d6bd6f..000000000
--- a/be/src/gutil/bind.h.pump
+++ /dev/null
@@ -1,153 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$
-$$ MAX_ARITY controls the number of arguments that Bind() supports.
-$$ The amount of code, and more importantly, the number of template types
-$$ generated by pump grows at O(MAX_ARITY^2).
-$$
-$$ We tried going to 11 and found it imposed an extra 10 penalty on windows
-$$ cycle times compared to our original baseline of 6.
-$$
-$$ Currently 7 is chosen as a compromise between supporting a convenient
-$$ number of arguments and keeping compile times low. At 7, we have 115
-$$ templates being generated by pump.
-$$
-$$ Be careful when adjusting this number. If people find a need to bind
-$$ a larger number of arguments, consider refactoring the function to use
-$$ a param struct instead of raising the MAX_ARITY.
-$$
-$$ See http://crbug.com/98542 for more context.
-$$
-$var MAX_ARITY = 7
-
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_BIND_H_
-#define GUTIL_BIND_H_
-
-#include "gutil/bind_internal.h"
-#include "gutil/callback_internal.h"
-
-// -----------------------------------------------------------------------------
-// Usage documentation
-// -----------------------------------------------------------------------------
-//
-// See gutil/callback.h for documentation.
-//
-//
-// -----------------------------------------------------------------------------
-// Implementation notes
-// -----------------------------------------------------------------------------
-//
-// If you're reading the implementation, before proceeding further, you should
-// read the top comment of gutil/bind_internal.h for a definition of common
-// terms and concepts.
-//
-// RETURN TYPES
-//
-// Though Bind()'s result is meant to be stored in a Callback<> type, it
-// cannot actually return the exact type without requiring a large amount
-// of extra template specializations. The problem is that in order to
-// discern the correct specialization of Callback<>, Bind would need to
-// unwrap the function signature to determine the signature's arity, and
-// whether or not it is a method.
-//
-// Each unique combination of (arity, function_type, num_prebound) where
-// function_type is one of {function, method, const_method} would require
-// one specialization. We eventually have to do a similar number of
-// specializations anyways in the implementation (see the Invoker<>,
-// classes). However, it is avoidable in Bind if we return the result
-// via an indirection like we do below.
-//
-// TODO(ajwong): We might be able to avoid this now, but need to test.
-//
-// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>,
-// but it feels a little nicer to have the asserts here so people do not
-// need to crack open bind_internal.h. On the other hand, it makes Bind()
-// harder to read.
-
-namespace kudu {
-
-$range ARITY 0..MAX_ARITY
-$for ARITY [[
-$range ARG 1..ARITY
-
-template <typename Functor[[]]
-$if ARITY > 0 [[, ]] $for ARG , [[typename P$(ARG)]]>
-Callback<
- typename internal::BindState<
- typename internal::FunctorTraits<Functor>::RunnableType,
- typename internal::FunctorTraits<Functor>::RunType,
- void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]])>
- ::UnboundRunType>
-Bind(Functor functor
-$if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]]) {
- // Typedefs for how to store and run the functor.
- typedef typename internal::FunctorTraits<Functor>::RunnableType RunnableType;
- typedef typename internal::FunctorTraits<Functor>::RunType RunType;
-
-$if ARITY > 0 [[
-
- // Use RunnableType::RunType instead of RunType above because our
- // checks should below for bound references need to know what the actual
- // functor is going to interpret the argument as.
- typedef internal::FunctionTraits<typename RunnableType::RunType>
- BoundFunctorTraits;
-
- // Do not allow binding a non-const reference parameter. Non-const reference
- // parameters are disallowed by the Google style guide. Also, binding a
- // non-const reference parameter can make for subtle bugs because the
- // invoked function will receive a reference to the stored copy of the
- // argument and not the original.
- COMPILE_ASSERT(
- !($for ARG || [[
-base::is_non_const_reference<typename BoundFunctorTraits::A$(ARG)Type>::value ]]),
- do_not_bind_functions_with_nonconst_ref);
-
-]]
-
-
-$for ARG [[
-
-
-$if ARG == 1 [[
- // For methods, we need to be careful for parameter 1. We do not require
- // a scoped_refptr because BindState<> itself takes care of AddRef() for
- // methods. We also disallow binding of an array as the method's target
- // object.
- COMPILE_ASSERT(
- internal::HasIsMethodTag<RunnableType>::value ||
- !internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value,
- p$(ARG)_is_refcounted_type_and_needs_scoped_refptr);
- COMPILE_ASSERT(!internal::HasIsMethodTag<RunnableType>::value ||
- !base::is_array<P$(ARG)>::value,
- first_bound_argument_to_method_cannot_be_array);
-]] $else [[
- COMPILE_ASSERT(!internal::NeedsScopedRefptrButGetsRawPtr<P$(ARG)>::value,
- p$(ARG)_is_refcounted_type_and_needs_scoped_refptr);
-]] $$ $if ARG
-
-]] $$ $for ARG
-
- typedef internal::BindState<RunnableType, RunType, [[]]
-void($for ARG , [[typename internal::CallbackParamTraits<P$(ARG)>::StorageType]])> [[]]
-BindState;
-
-
- return Callback<typename BindState::UnboundRunType>(
- new BindState(internal::MakeRunnable(functor)[[]]
-$if ARITY > 0 [[, ]] $for ARG , [[p$(ARG)]]));
-}
-
-]] $$ for ARITY
-
-} // namespace kudu
-
-#endif // GUTIL_BIND_H_
diff --git a/be/src/gutil/bind_helpers.h b/be/src/gutil/bind_helpers.h
deleted file mode 100644
index a60b518ba..000000000
--- a/be/src/gutil/bind_helpers.h
+++ /dev/null
@@ -1,551 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This defines a set of argument wrappers and related factory methods that
-// can be used specify the refcounting and reference semantics of arguments
-// that are bound by the Bind() function in kudu/gutil/bind.h.
-//
-// It also defines a set of simple functions and utilities that people want
-// when using Callback<> and Bind().
-//
-//
-// ARGUMENT BINDING WRAPPERS
-//
-// The wrapper functions are kudu::Unretained(), kudu::Owned(), kudu::Passed(),
-// kudu::ConstRef(), and kudu::IgnoreResult().
-//
-// Unretained() allows Bind() to bind a non-refcounted class, and to disable
-// refcounting on arguments that are refcounted objects.
-//
-// Owned() transfers ownership of an object to the Callback resulting from
-// bind; the object will be deleted when the Callback is deleted.
-//
-// Passed() is for transferring movable-but-not-copyable types (eg. scoped_ptr)
-// through a Callback. Logically, this signifies a destructive transfer of
-// the state of the argument into the target function. Invoking
-// Callback::Run() twice on a Callback that was created with a Passed()
-// argument will CHECK() because the first invocation would have already
-// transferred ownership to the target function.
-//
-// ConstRef() allows binding a constant reference to an argument rather
-// than a copy.
-//
-// IgnoreResult() is used to adapt a function or Callback with a return type to
-// one with a void return. This is most useful if you have a function with,
-// say, a pesky ignorable bool return that you want to use with PostTask or
-// something else that expect a Callback with a void return.
-//
-// EXAMPLE OF Unretained():
-//
-// class Foo {
-// public:
-// void func() { cout << "Foo:f" << endl; }
-// };
-//
-// // In some function somewhere.
-// Foo foo;
-// Closure foo_callback =
-// Bind(&Foo::func, Unretained(&foo));
-// foo_callback.Run(); // Prints "Foo:f".
-//
-// Without the Unretained() wrapper on |&foo|, the above call would fail
-// to compile because Foo does not support the AddRef() and Release() methods.
-//
-//
-// EXAMPLE OF Owned():
-//
-// void foo(int* arg) { cout << *arg << endl }
-//
-// int* pn = new int(1);
-// Closure foo_callback = Bind(&foo, Owned(pn));
-//
-// foo_callback.Run(); // Prints "1"
-// foo_callback.Run(); // Prints "1"
-// *n = 2;
-// foo_callback.Run(); // Prints "2"
-//
-// foo_callback.Reset(); // |pn| is deleted. Also will happen when
-// // |foo_callback| goes out of scope.
-//
-// Without Owned(), someone would have to know to delete |pn| when the last
-// reference to the Callback is deleted.
-//
-//
-// EXAMPLE OF ConstRef():
-//
-// void foo(int arg) { cout << arg << endl }
-//
-// int n = 1;
-// Closure no_ref = Bind(&foo, n);
-// Closure has_ref = Bind(&foo, ConstRef(n));
-//
-// no_ref.Run(); // Prints "1"
-// has_ref.Run(); // Prints "1"
-//
-// n = 2;
-// no_ref.Run(); // Prints "1"
-// has_ref.Run(); // Prints "2"
-//
-// Note that because ConstRef() takes a reference on |n|, |n| must outlive all
-// its bound callbacks.
-//
-//
-// EXAMPLE OF IgnoreResult():
-//
-// int DoSomething(int arg) { cout << arg << endl; }
-//
-// // Assign to a Callback with a void return type.
-// Callback<void(int)> cb = Bind(IgnoreResult(&DoSomething));
-// cb->Run(1); // Prints "1".
-//
-// // Prints "1" on |ml|.
-// ml->PostTask(FROM_HERE, Bind(IgnoreResult(&DoSomething), 1);
-//
-//
-// EXAMPLE OF Passed():
-//
-// void TakesOwnership(scoped_ptr<Foo> arg) { }
-// scoped_ptr<Foo> CreateFoo() { return scoped_ptr<Foo>(new Foo()); }
-//
-// scoped_ptr<Foo> f(new Foo());
-//
-// // |cb| is given ownership of Foo(). |f| is now NULL.
-// // You can use f.Pass() in place of &f, but it's more verbose.
-// Closure cb = Bind(&TakesOwnership, Passed(&f));
-//
-// // Run was never called so |cb| still owns Foo() and deletes
-// // it on Reset().
-// cb.Reset();
-//
-// // |cb| is given a new Foo created by CreateFoo().
-// cb = Bind(&TakesOwnership, Passed(CreateFoo()));
-//
-// // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
-// // no longer owns Foo() and, if reset, would not delete Foo().
-// cb.Run(); // Foo() is now transferred to |arg| and deleted.
-// cb.Run(); // This CHECK()s since Foo() already been used once.
-//
-// Passed() is particularly useful with PostTask() when you are transferring
-// ownership of an argument into a task, but don't necessarily know if the
-// task will always be executed. This can happen if the task is cancellable
-// or if it is posted to a MessageLoopProxy.
-//
-//
-// SIMPLE FUNCTIONS AND UTILITIES.
-//
-// DoNothing() - Useful for creating a Closure that does nothing when called.
-// DeletePointer<T>() - Useful for creating a Closure that will delete a
-// pointer when invoked. Only use this when necessary.
-// In most cases MessageLoop::DeleteSoon() is a better
-// fit.
-
-#ifndef GUTIL_BIND_HELPERS_H_
-#define GUTIL_BIND_HELPERS_H_
-
-#include <assert.h>
-
-#include "gutil/basictypes.h"
-#include "gutil/callback.h"
-#include "gutil/template_util.h"
-
-// Unneeded define from Chromium
-#define BASE_EXPORT
-
-
-namespace kudu {
-namespace internal {
-
-// Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T
-// for the existence of AddRef() and Release() functions of the correct
-// signature.
-//
-// http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error
-// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
-// http://stackoverflow.com/questions/4358584/sfinae-approach-comparison
-// http://stackoverflow.com/questions/1966362/sfinae-to-check-for-inherited-member-functions
-//
-// The last link in particular show the method used below.
-//
-// For SFINAE to work with inherited methods, we need to pull some extra tricks
-// with multiple inheritance. In the more standard formulation, the overloads
-// of Check would be:
-//
-// template <typename C>
-// Yes NotTheCheckWeWant(Helper<&C::TargetFunc>*);
-//
-// template <typename C>
-// No NotTheCheckWeWant(...);
-//
-// static const bool value = sizeof(NotTheCheckWeWant<T>(0)) == sizeof(Yes);
-//
-// The problem here is that template resolution will not match
-// C::TargetFunc if TargetFunc does not exist directly in C. That is, if
-// TargetFunc in inherited from an ancestor, &C::TargetFunc will not match,
-// |value| will be false. This formulation only checks for whether or
-// not TargetFunc exist directly in the class being introspected.
-//
-// To get around this, we play a dirty trick with multiple inheritance.
-// First, We create a class BaseMixin that declares each function that we
-// want to probe for. Then we create a class Base that inherits from both T
-// (the class we wish to probe) and BaseMixin. Note that the function
-// signature in BaseMixin does not need to match the signature of the function
-// we are probing for; thus it's easiest to just use void(void).
-//
-// Now, if TargetFunc exists somewhere in T, then &Base::TargetFunc has an
-// ambiguous resolution between BaseMixin and T. This lets us write the
-// following:
-//
-// template <typename C>
-// No GoodCheck(Helper<&C::TargetFunc>*);
-//
-// template <typename C>
-// Yes GoodCheck(...);
-//
-// static const bool value = sizeof(GoodCheck<Base>(0)) == sizeof(Yes);
-//
-// Notice here that the variadic version of GoodCheck() returns Yes here
-// instead of No like the previous one. Also notice that we calculate |value|
-// by specializing GoodCheck() on Base instead of T.
-//
-// We've reversed the roles of the variadic, and Helper overloads.
-// GoodCheck(Helper<&C::TargetFunc>*), when C = Base, fails to be a valid
-// substitution if T::TargetFunc exists. Thus GoodCheck<Base>(0) will resolve
-// to the variadic version if T has TargetFunc. If T::TargetFunc does not
-// exist, then &C::TargetFunc is not ambiguous, and the overload resolution
-// will prefer GoodCheck(Helper<&C::TargetFunc>*).
-//
-// This method of SFINAE will correctly probe for inherited names, but it cannot
-// typecheck those names. It's still a good enough sanity check though.
-//
-// Works on gcc-4.2, gcc-4.4, and Visual Studio 2008.
-//
-// TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted
-// this works well.
-//
-// TODO(ajwong): Make this check for Release() as well.
-// See http://crbug.com/82038.
-template <typename T>
-class SupportsAddRefAndRelease {
- typedef char Yes[1];
- typedef char No[2];
-
- struct BaseMixin {
- void AddRef();
- };
-
-// MSVC warns when you try to use Base if T has a private destructor, the
-// common pattern for refcounted types. It does this even though no attempt to
-// instantiate Base is made. We disable the warning for this definition.
-#if defined(OS_WIN)
-#pragma warning(push)
-#pragma warning(disable:4624)
-#endif
- struct Base : public T, public BaseMixin {
- };
-#if defined(OS_WIN)
-#pragma warning(pop)
-#endif
-
- template <void(BaseMixin::*)(void)> struct Helper {};
-
- template <typename C>
- static No& Check(Helper<&C::AddRef>*);
-
- template <typename >
- static Yes& Check(...);
-
- public:
- static const bool value = sizeof(Check<Base>(0)) == sizeof(Yes);
-};
-
-// Helpers to assert that arguments of a recounted type are bound with a
-// scoped_refptr.
-template <bool IsClasstype, typename T>
-struct UnsafeBindtoRefCountedArgHelper : base::false_type {
-};
-
-template <typename T>
-struct UnsafeBindtoRefCountedArgHelper<true, T>
- : base::integral_constant<bool, SupportsAddRefAndRelease<T>::value> {
-};
-
-template <typename T>
-struct UnsafeBindtoRefCountedArg : base::false_type {
-};
-
-template <typename T>
-struct UnsafeBindtoRefCountedArg<T*>
- : UnsafeBindtoRefCountedArgHelper<base::is_class<T>::value, T> {
-};
-
-template <typename T>
-class HasIsMethodTag {
- typedef char Yes[1];
- typedef char No[2];
-
- template <typename U>
- static Yes& Check(typename U::IsMethod*);
-
- template <typename U>
- static No& Check(...);
-
- public:
- static const bool value = sizeof(Check<T>(0)) == sizeof(Yes);
-};
-
-template <typename T>
-class UnretainedWrapper {
- public:
- explicit UnretainedWrapper(T* o) : ptr_(o) {}
- T* get() const { return ptr_; }
- private:
- T* ptr_;
-};
-
-template <typename T>
-class ConstRefWrapper {
- public:
- explicit ConstRefWrapper(const T& o) : ptr_(&o) {}
- const T& get() const { return *ptr_; }
- private:
- const T* ptr_;
-};
-
-template <typename T>
-struct IgnoreResultHelper {
- explicit IgnoreResultHelper(T functor) : functor_(functor) {}
-
- T functor_;
-};
-
-template <typename T>
-struct IgnoreResultHelper<Callback<T> > {
- explicit IgnoreResultHelper(const Callback<T>& functor) : functor_(functor) {}
-
- const Callback<T>& functor_;
-};
-
-// An alternate implementation is to avoid the destructive copy, and instead
-// specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to
-// a class that is essentially a scoped_ptr<>.
-//
-// The current implementation has the benefit though of leaving ParamTraits<>
-// fully in callback_internal.h as well as avoiding type conversions during
-// storage.
-template <typename T>
-class OwnedWrapper {
- public:
- explicit OwnedWrapper(T* o) : ptr_(o) {}
- ~OwnedWrapper() { delete ptr_; }
- T* get() const { return ptr_; }
- OwnedWrapper(const OwnedWrapper& other) {
- ptr_ = other.ptr_;
- other.ptr_ = NULL;
- }
-
- private:
- mutable T* ptr_;
-};
-
-// PassedWrapper is a copyable adapter for a scoper that ignores const.
-//
-// It is needed to get around the fact that Bind() takes a const reference to
-// all its arguments. Because Bind() takes a const reference to avoid
-// unnecessary copies, it is incompatible with movable-but-not-copyable
-// types; doing a destructive "move" of the type into Bind() would violate
-// the const correctness.
-//
-// This conundrum cannot be solved without either C++11 rvalue references or
-// a O(2^n) blowup of Bind() templates to handle each combination of regular
-// types and movable-but-not-copyable types. Thus we introduce a wrapper type
-// that is copyable to transmit the correct type information down into
-// BindState<>. Ignoring const in this type makes sense because it is only
-// created when we are explicitly trying to do a destructive move.
-//
-// Two notes:
-// 1) PassedWrapper supports any type that has a "Pass()" function.
-// This is intentional. The whitelisting of which specific types we
-// support is maintained by CallbackParamTraits<>.
-// 2) is_valid_ is distinct from NULL because it is valid to bind a "NULL"
-// scoper to a Callback and allow the Callback to execute once.
-template <typename T>
-class PassedWrapper {
- public:
- explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {}
- PassedWrapper(const PassedWrapper& other)
- : is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {
- }
- T Pass() const {
- assert(is_valid_);
- is_valid_ = false;
- return scoper_.Pass();
- }
-
- private:
- mutable bool is_valid_;
- mutable T scoper_;
-};
-
-// Unwrap the stored parameters for the wrappers above.
-template <typename T>
-struct UnwrapTraits {
- typedef const T& ForwardType;
- static ForwardType Unwrap(const T& o) { return o; }
-};
-
-template <typename T>
-struct UnwrapTraits<UnretainedWrapper<T> > {
- typedef T* ForwardType;
- static ForwardType Unwrap(UnretainedWrapper<T> unretained) {
- return unretained.get();
- }
-};
-
-template <typename T>
-struct UnwrapTraits<ConstRefWrapper<T> > {
- typedef const T& ForwardType;
- static ForwardType Unwrap(ConstRefWrapper<T> const_ref) {
- return const_ref.get();
- }
-};
-
-template <typename T>
-struct UnwrapTraits<scoped_refptr<T> > {
- typedef T* ForwardType;
- static ForwardType Unwrap(const scoped_refptr<T>& o) { return o.get(); }
-};
-
-// We didn't import WeakPtr from Chromium.
-//
-//template <typename T>
-//struct UnwrapTraits<WeakPtr<T> > {
-// typedef const WeakPtr<T>& ForwardType;
-// static ForwardType Unwrap(const WeakPtr<T>& o) { return o; }
-//};
-
-template <typename T>
-struct UnwrapTraits<OwnedWrapper<T> > {
- typedef T* ForwardType;
- static ForwardType Unwrap(const OwnedWrapper<T>& o) {
- return o.get();
- }
-};
-
-template <typename T>
-struct UnwrapTraits<PassedWrapper<T> > {
- typedef T ForwardType;
- static T Unwrap(PassedWrapper<T>& o) {
- return o.Pass();
- }
-};
-
-// Utility for handling different refcounting semantics in the Bind()
-// function.
-template <bool is_method, typename T>
-struct MaybeRefcount;
-
-template <typename T>
-struct MaybeRefcount<false, T> {
- static void AddRef(const T&) {}
- static void Release(const T&) {}
-};
-
-template <typename T, size_t n>
-struct MaybeRefcount<false, T[n]> {
- static void AddRef(const T*) {}
- static void Release(const T*) {}
-};
-
-template <typename T>
-struct MaybeRefcount<true, T> {
- static void AddRef(const T&) {}
- static void Release(const T&) {}
-};
-
-template <typename T>
-struct MaybeRefcount<true, T*> {
- static void AddRef(T* o) { o->AddRef(); }
- static void Release(T* o) { o->Release(); }
-};
-
-// No need to additionally AddRef() and Release() since we are storing a
-// scoped_refptr<> inside the storage object already.
-template <typename T>
-struct MaybeRefcount<true, scoped_refptr<T> > {
- static void AddRef(const scoped_refptr<T>& o) {}
- static void Release(const scoped_refptr<T>& o) {}
-};
-
-template <typename T>
-struct MaybeRefcount<true, const T*> {
- static void AddRef(const T* o) { o->AddRef(); }
- static void Release(const T* o) { o->Release(); }
-};
-
-// We didn't import WeakPtr from Chromium.
-//
-//// IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a
-//// method. It is used internally by Bind() to select the correct
-//// InvokeHelper that will no-op itself in the event the WeakPtr<> for
-//// the target object is invalidated.
-////
-//// P1 should be the type of the object that will be received of the method.
-//template <bool IsMethod, typename P1>
-//struct IsWeakMethod : public false_type {};
-//
-//template <typename T>
-//struct IsWeakMethod<true, WeakPtr<T> > : public true_type {};
-//
-//template <typename T>
-//struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T> > > : public true_type {};
-
-} // namespace internal
-
-template <typename T>
-static inline internal::UnretainedWrapper<T> Unretained(T* o) {
- return internal::UnretainedWrapper<T>(o);
-}
-
-template <typename T>
-static inline internal::ConstRefWrapper<T> ConstRef(const T& o) {
- return internal::ConstRefWrapper<T>(o);
-}
-
-template <typename T>
-static inline internal::OwnedWrapper<T> Owned(T* o) {
- return internal::OwnedWrapper<T>(o);
-}
-
-// We offer 2 syntaxes for calling Passed(). The first takes a temporary and
-// is best suited for use with the return value of a function. The second
-// takes a pointer to the scoper and is just syntactic sugar to avoid having
-// to write Passed(scoper.Pass()).
-template <typename T>
-static inline internal::PassedWrapper<T> Passed(T scoper) {
- return internal::PassedWrapper<T>(scoper.Pass());
-}
-template <typename T>
-static inline internal::PassedWrapper<T> Passed(T* scoper) {
- return internal::PassedWrapper<T>(scoper->Pass());
-}
-
-template <typename T>
-static inline internal::IgnoreResultHelper<T> IgnoreResult(T data) {
- return internal::IgnoreResultHelper<T>(data);
-}
-
-template <typename T>
-static inline internal::IgnoreResultHelper<Callback<T> >
-IgnoreResult(const Callback<T>& data) {
- return internal::IgnoreResultHelper<Callback<T> >(data);
-}
-
-template<typename T>
-void DeletePointer(T* obj) {
- delete obj;
-}
-
-} // namespace kudu
-
-#endif // BASE_BIND_HELPERS_H_
diff --git a/be/src/gutil/bind_internal.h b/be/src/gutil/bind_internal.h
deleted file mode 100644
index 639e07744..000000000
--- a/be/src/gutil/bind_internal.h
+++ /dev/null
@@ -1,2695 +0,0 @@
-// This file was GENERATED by command:
-// pump.py bind_internal.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_BIND_INTERNAL_H_
-#define GUTIL_BIND_INTERNAL_H_
-
-#include "gutil/bind_helpers.h"
-#include "gutil/callback_internal.h"
-#include "gutil/raw_scoped_refptr_mismatch_checker.h"
-#include "gutil/template_util.h"
-
-#if defined(OS_WIN)
-#include "gutil/bind_internal_win.h"
-#endif
-
-// During Chromium import, WeakPtr-related code was removed.
-
-namespace kudu {
-namespace internal {
-
-// See kudu/gutil/callback.h for user documentation.
-//
-//
-// CONCEPTS:
-// Runnable -- A type (really a type class) that has a single Run() method
-// and a RunType typedef that corresponds to the type of Run().
-// A Runnable can declare that it should treated like a method
-// call by including a typedef named IsMethod. The value of
-// this typedef is NOT inspected, only the existence. When a
-// Runnable declares itself a method, Bind() will enforce special
-// refcounting + WeakPtr handling semantics for the first
-// parameter which is expected to be an object.
-// Functor -- A copyable type representing something that should be called.
-// All function pointers, Callback<>, and Runnables are functors
-// even if the invocation syntax differs.
-// RunType -- A function type (as opposed to function _pointer_ type) for
-// a Run() function. Usually just a convenience typedef.
-// (Bound)ArgsType -- A function type that is being (ab)used to store the
-// types of set of arguments. The "return" type is always
-// void here. We use this hack so that we do not need
-// a new type name for each arity of type. (eg.,
-// BindState1, BindState2). This makes forward
-// declarations and friending much much easier.
-//
-// Types:
-// RunnableAdapter<> -- Wraps the various "function" pointer types into an
-// object that adheres to the Runnable interface.
-// There are |3*ARITY| RunnableAdapter types.
-// FunctionTraits<> -- Type traits that unwrap a function signature into a
-// a set of easier to use typedefs. Used mainly for
-// compile time asserts.
-// There are |ARITY| FunctionTraits types.
-// ForceVoidReturn<> -- Helper class for translating function signatures to
-// equivalent forms with a "void" return type.
-// There are |ARITY| ForceVoidReturn types.
-// FunctorTraits<> -- Type traits used determine the correct RunType and
-// RunnableType for a Functor. This is where function
-// signature adapters are applied.
-// There are |ARITY| ForceVoidReturn types.
-// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable
-// type class that represents the underlying Functor.
-// There are |O(1)| MakeRunnable types.
-// InvokeHelper<> -- Take a Runnable + arguments and actully invokes it.
-// Handle the differing syntaxes needed for WeakPtr<> support,
-// and for ignoring return values. This is separate from
-// Invoker to avoid creating multiple version of Invoker<>
-// which grows at O(n^2) with the arity.
-// There are |k*ARITY| InvokeHelper types.
-// Invoker<> -- Unwraps the curried parameters and executes the Runnable.
-// There are |(ARITY^2 + ARITY)/2| Invoketypes.
-// BindState<> -- Stores the curried parameters, and is the main entry point
-// into the Bind() system, doing most of the type resolution.
-// There are ARITY BindState types.
-
-// RunnableAdapter<>
-//
-// The RunnableAdapter<> templates provide a uniform interface for invoking
-// a function pointer, method pointer, or const method pointer. The adapter
-// exposes a Run() method with an appropriate signature. Using this wrapper
-// allows for writing code that supports all three pointer types without
-// undue repetition. Without it, a lot of code would need to be repeated 3
-// times.
-//
-// For method pointers and const method pointers the first argument to Run()
-// is considered to be the received of the method. This is similar to STL's
-// mem_fun().
-//
-// This class also exposes a RunType typedef that is the function type of the
-// Run() function.
-//
-// If and only if the wrapper contains a method or const method pointer, an
-// IsMethod typedef is exposed. The existence of this typedef (NOT the value)
-// marks that the wrapper should be considered a method wrapper.
-
-template <typename Functor>
-class RunnableAdapter;
-
-// Function: Arity 0.
-template <typename R>
-class RunnableAdapter<R(*)()> {
- public:
- typedef R (RunType)();
-
- explicit RunnableAdapter(R(*function)())
- : function_(function) {
- }
-
- R Run() {
- return function_();
- }
-
- private:
- R (*function_)();
-};
-
-// Method: Arity 0.
-template <typename R, typename T>
-class RunnableAdapter<R(T::*)()> {
- public:
- typedef R (RunType)(T*);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)())
- : method_(method) {
- }
-
- R Run(T* object) {
- return (object->*method_)();
- }
-
- private:
- R (T::*method_)();
-};
-
-// Const Method: Arity 0.
-template <typename R, typename T>
-class RunnableAdapter<R(T::*)() const> {
- public:
- typedef R (RunType)(const T*);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)() const)
- : method_(method) {
- }
-
- R Run(const T* object) {
- return (object->*method_)();
- }
-
- private:
- R (T::*method_)() const;
-};
-
-// Function: Arity 1.
-template <typename R, typename A1>
-class RunnableAdapter<R(*)(A1)> {
- public:
- typedef R (RunType)(A1);
-
- explicit RunnableAdapter(R(*function)(A1))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
- return function_(CallbackForward(a1));
- }
-
- private:
- R (*function_)(A1);
-};
-
-// Method: Arity 1.
-template <typename R, typename T, typename A1>
-class RunnableAdapter<R(T::*)(A1)> {
- public:
- typedef R (RunType)(T*, A1);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
- return (object->*method_)(CallbackForward(a1));
- }
-
- private:
- R (T::*method_)(A1);
-};
-
-// Const Method: Arity 1.
-template <typename R, typename T, typename A1>
-class RunnableAdapter<R(T::*)(A1) const> {
- public:
- typedef R (RunType)(const T*, A1);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1) {
- return (object->*method_)(CallbackForward(a1));
- }
-
- private:
- R (T::*method_)(A1) const;
-};
-
-// Function: Arity 2.
-template <typename R, typename A1, typename A2>
-class RunnableAdapter<R(*)(A1, A2)> {
- public:
- typedef R (RunType)(A1, A2);
-
- explicit RunnableAdapter(R(*function)(A1, A2))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2) {
- return function_(CallbackForward(a1), CallbackForward(a2));
- }
-
- private:
- R (*function_)(A1, A2);
-};
-
-// Method: Arity 2.
-template <typename R, typename T, typename A1, typename A2>
-class RunnableAdapter<R(T::*)(A1, A2)> {
- public:
- typedef R (RunType)(T*, A1, A2);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
- }
-
- private:
- R (T::*method_)(A1, A2);
-};
-
-// Const Method: Arity 2.
-template <typename R, typename T, typename A1, typename A2>
-class RunnableAdapter<R(T::*)(A1, A2) const> {
- public:
- typedef R (RunType)(const T*, A1, A2);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2));
- }
-
- private:
- R (T::*method_)(A1, A2) const;
-};
-
-// Function: Arity 3.
-template <typename R, typename A1, typename A2, typename A3>
-class RunnableAdapter<R(*)(A1, A2, A3)> {
- public:
- typedef R (RunType)(A1, A2, A3);
-
- explicit RunnableAdapter(R(*function)(A1, A2, A3))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3) {
- return function_(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3));
- }
-
- private:
- R (*function_)(A1, A2, A3);
-};
-
-// Method: Arity 3.
-template <typename R, typename T, typename A1, typename A2, typename A3>
-class RunnableAdapter<R(T::*)(A1, A2, A3)> {
- public:
- typedef R (RunType)(T*, A1, A2, A3);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3));
- }
-
- private:
- R (T::*method_)(A1, A2, A3);
-};
-
-// Const Method: Arity 3.
-template <typename R, typename T, typename A1, typename A2, typename A3>
-class RunnableAdapter<R(T::*)(A1, A2, A3) const> {
- public:
- typedef R (RunType)(const T*, A1, A2, A3);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3));
- }
-
- private:
- R (T::*method_)(A1, A2, A3) const;
-};
-
-// Function: Arity 4.
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-class RunnableAdapter<R(*)(A1, A2, A3, A4)> {
- public:
- typedef R (RunType)(A1, A2, A3, A4);
-
- explicit RunnableAdapter(R(*function)(A1, A2, A3, A4))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4) {
- return function_(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4));
- }
-
- private:
- R (*function_)(A1, A2, A3, A4);
-};
-
-// Method: Arity 4.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4)> {
- public:
- typedef R (RunType)(T*, A1, A2, A3, A4);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4);
-};
-
-// Const Method: Arity 4.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4) const> {
- public:
- typedef R (RunType)(const T*, A1, A2, A3, A4);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4) const;
-};
-
-// Function: Arity 5.
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5>
-class RunnableAdapter<R(*)(A1, A2, A3, A4, A5)> {
- public:
- typedef R (RunType)(A1, A2, A3, A4, A5);
-
- explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5) {
- return function_(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
- }
-
- private:
- R (*function_)(A1, A2, A3, A4, A5);
-};
-
-// Method: Arity 5.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5)> {
- public:
- typedef R (RunType)(T*, A1, A2, A3, A4, A5);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5);
-};
-
-// Const Method: Arity 5.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5) const> {
- public:
- typedef R (RunType)(const T*, A1, A2, A3, A4, A5);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5) const;
-};
-
-// Function: Arity 6.
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6)> {
- public:
- typedef R (RunType)(A1, A2, A3, A4, A5, A6);
-
- explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6) {
- return function_(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6));
- }
-
- private:
- R (*function_)(A1, A2, A3, A4, A5, A6);
-};
-
-// Method: Arity 6.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5, typename A6>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6)> {
- public:
- typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5, A6);
-};
-
-// Const Method: Arity 6.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5, typename A6>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6) const> {
- public:
- typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5, A6) const;
-};
-
-// Function: Arity 7.
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-class RunnableAdapter<R(*)(A1, A2, A3, A4, A5, A6, A7)> {
- public:
- typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
-
- explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7))
- : function_(function) {
- }
-
- R Run(typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6,
- typename CallbackParamTraits<A7>::ForwardType a7) {
- return function_(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6), CallbackForward(a7));
- }
-
- private:
- R (*function_)(A1, A2, A3, A4, A5, A6, A7);
-};
-
-// Method: Arity 7.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5, typename A6, typename A7>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7)> {
- public:
- typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7))
- : method_(method) {
- }
-
- R Run(T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6,
- typename CallbackParamTraits<A7>::ForwardType a7) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6), CallbackForward(a7));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5, A6, A7);
-};
-
-// Const Method: Arity 7.
-template <typename R, typename T, typename A1, typename A2, typename A3,
- typename A4, typename A5, typename A6, typename A7>
-class RunnableAdapter<R(T::*)(A1, A2, A3, A4, A5, A6, A7) const> {
- public:
- typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const)
- : method_(method) {
- }
-
- R Run(const T* object, typename CallbackParamTraits<A1>::ForwardType a1,
- typename CallbackParamTraits<A2>::ForwardType a2,
- typename CallbackParamTraits<A3>::ForwardType a3,
- typename CallbackParamTraits<A4>::ForwardType a4,
- typename CallbackParamTraits<A5>::ForwardType a5,
- typename CallbackParamTraits<A6>::ForwardType a6,
- typename CallbackParamTraits<A7>::ForwardType a7) {
- return (object->*method_)(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6), CallbackForward(a7));
- }
-
- private:
- R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const;
-};
-
-
-// FunctionTraits<>
-//
-// Breaks a function signature apart into typedefs for easier introspection.
-template <typename Sig>
-struct FunctionTraits;
-
-template <typename R>
-struct FunctionTraits<R()> {
- typedef R ReturnType;
-};
-
-template <typename R, typename A1>
-struct FunctionTraits<R(A1)> {
- typedef R ReturnType;
- typedef A1 A1Type;
-};
-
-template <typename R, typename A1, typename A2>
-struct FunctionTraits<R(A1, A2)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-struct FunctionTraits<R(A1, A2, A3)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
- typedef A3 A3Type;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-struct FunctionTraits<R(A1, A2, A3, A4)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
- typedef A3 A3Type;
- typedef A4 A4Type;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5>
-struct FunctionTraits<R(A1, A2, A3, A4, A5)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
- typedef A3 A3Type;
- typedef A4 A4Type;
- typedef A5 A5Type;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-struct FunctionTraits<R(A1, A2, A3, A4, A5, A6)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
- typedef A3 A3Type;
- typedef A4 A4Type;
- typedef A5 A5Type;
- typedef A6 A6Type;
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-struct FunctionTraits<R(A1, A2, A3, A4, A5, A6, A7)> {
- typedef R ReturnType;
- typedef A1 A1Type;
- typedef A2 A2Type;
- typedef A3 A3Type;
- typedef A4 A4Type;
- typedef A5 A5Type;
- typedef A6 A6Type;
- typedef A7 A7Type;
-};
-
-
-// ForceVoidReturn<>
-//
-// Set of templates that support forcing the function return type to void.
-template <typename Sig>
-struct ForceVoidReturn;
-
-template <typename R>
-struct ForceVoidReturn<R()> {
- typedef void(RunType)();
-};
-
-template <typename R, typename A1>
-struct ForceVoidReturn<R(A1)> {
- typedef void(RunType)(A1);
-};
-
-template <typename R, typename A1, typename A2>
-struct ForceVoidReturn<R(A1, A2)> {
- typedef void(RunType)(A1, A2);
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-struct ForceVoidReturn<R(A1, A2, A3)> {
- typedef void(RunType)(A1, A2, A3);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-struct ForceVoidReturn<R(A1, A2, A3, A4)> {
- typedef void(RunType)(A1, A2, A3, A4);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5>
-struct ForceVoidReturn<R(A1, A2, A3, A4, A5)> {
- typedef void(RunType)(A1, A2, A3, A4, A5);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6)> {
- typedef void(RunType)(A1, A2, A3, A4, A5, A6);
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-struct ForceVoidReturn<R(A1, A2, A3, A4, A5, A6, A7)> {
- typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7);
-};
-
-
-// FunctorTraits<>
-//
-// See description at top of file.
-template <typename T>
-struct FunctorTraits {
- typedef RunnableAdapter<T> RunnableType;
- typedef typename RunnableType::RunType RunType;
-};
-
-template <typename T>
-struct FunctorTraits<IgnoreResultHelper<T> > {
- typedef typename FunctorTraits<T>::RunnableType RunnableType;
- typedef typename ForceVoidReturn<
- typename RunnableType::RunType>::RunType RunType;
-};
-
-template <typename T>
-struct FunctorTraits<Callback<T> > {
- typedef Callback<T> RunnableType;
- typedef typename Callback<T>::RunType RunType;
-};
-
-
-// MakeRunnable<>
-//
-// Converts a passed in functor to a RunnableType using type inference.
-
-template <typename T>
-typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
- return RunnableAdapter<T>(t);
-}
-
-template <typename T>
-typename FunctorTraits<T>::RunnableType
-MakeRunnable(const IgnoreResultHelper<T>& t) {
- return MakeRunnable(t.functor_);
-}
-
-template <typename T>
-const typename FunctorTraits<Callback<T> >::RunnableType&
-MakeRunnable(const Callback<T>& t) {
- DCHECK(!t.is_null());
- return t;
-}
-
-
-// InvokeHelper<>
-//
-// There are 3 logical InvokeHelper<> specializations: normal, void-return,
-// WeakCalls.
-//
-// The normal type just calls the underlying runnable.
-//
-// We need a InvokeHelper to handle void return types in order to support
-// IgnoreResult(). Normally, if the Runnable's RunType had a void return,
-// the template system would just accept "return functor.Run()" ignoring
-// the fact that a void function is being used with return. This piece of
-// sugar breaks though when the Runnable's RunType is not void. Thus, we
-// need a partial specialization to change the syntax to drop the "return"
-// from the invocation call.
-//
-// WeakCalls similarly need special syntax that is applied to the first
-// argument to check if they should no-op themselves.
-template <bool IsWeakCall, typename ReturnType, typename Runnable,
- typename ArgsType>
-struct InvokeHelper;
-
-template <typename ReturnType, typename Runnable>
-struct InvokeHelper<false, ReturnType, Runnable,
- void()> {
- static ReturnType MakeItSo(Runnable runnable) {
- return runnable.Run();
- }
-};
-
-template <typename Runnable>
-struct InvokeHelper<false, void, Runnable,
- void()> {
- static void MakeItSo(Runnable runnable) {
- runnable.Run();
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1) {
- return runnable.Run(CallbackForward(a1));
- }
-};
-
-template <typename Runnable,typename A1>
-struct InvokeHelper<false, void, Runnable,
- void(A1)> {
- static void MakeItSo(Runnable runnable, A1 a1) {
- runnable.Run(CallbackForward(a1));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2));
- }
-};
-
-template <typename Runnable,typename A1, typename A2>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2,
- typename A3>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2, A3)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3));
- }
-};
-
-template <typename Runnable,typename A1, typename A2, typename A3>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2, A3)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2,
- typename A3, typename A4>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2, A3, A4)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4));
- }
-};
-
-template <typename Runnable,typename A1, typename A2, typename A3, typename A4>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2, A3, A4)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
- CallbackForward(a4));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2,
- typename A3, typename A4, typename A5>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2, A3, A4, A5)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
- A5 a5) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5));
- }
-};
-
-template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
- typename A5>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2, A3, A4, A5)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
- CallbackForward(a4), CallbackForward(a5));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2,
- typename A3, typename A4, typename A5, typename A6>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2, A3, A4, A5, A6)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
- A5 a5, A6 a6) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6));
- }
-};
-
-template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2, A3, A4, A5, A6)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
- A6 a6) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
- CallbackForward(a4), CallbackForward(a5), CallbackForward(a6));
- }
-};
-
-template <typename ReturnType, typename Runnable,typename A1, typename A2,
- typename A3, typename A4, typename A5, typename A6, typename A7>
-struct InvokeHelper<false, ReturnType, Runnable,
- void(A1, A2, A3, A4, A5, A6, A7)> {
- static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4,
- A5 a5, A6 a6, A7 a7) {
- return runnable.Run(CallbackForward(a1), CallbackForward(a2),
- CallbackForward(a3), CallbackForward(a4), CallbackForward(a5),
- CallbackForward(a6), CallbackForward(a7));
- }
-};
-
-template <typename Runnable,typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-struct InvokeHelper<false, void, Runnable,
- void(A1, A2, A3, A4, A5, A6, A7)> {
- static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5,
- A6 a6, A7 a7) {
- runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3),
- CallbackForward(a4), CallbackForward(a5), CallbackForward(a6),
- CallbackForward(a7));
- }
-};
-
-// Invoker<>
-//
-// See description at the top of the file.
-template <int NumBound, typename Storage, typename RunType>
-struct Invoker;
-
-// Arity 0 -> 0.
-template <typename StorageType, typename R>
-struct Invoker<0, StorageType, R()> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void()>
- ::MakeItSo(storage->runnable_);
- }
-};
-
-// Arity 1 -> 1.
-template <typename StorageType, typename R,typename X1>
-struct Invoker<0, StorageType, R(X1)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType);
-
- typedef R(UnboundRunType)(X1);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1));
- }
-};
-
-// Arity 1 -> 0.
-template <typename StorageType, typename R,typename X1>
-struct Invoker<1, StorageType, R(X1)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1));
- }
-};
-
-// Arity 2 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2>
-struct Invoker<0, StorageType, R(X1, X2)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2));
- }
-};
-
-// Arity 2 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2>
-struct Invoker<1, StorageType, R(X1, X2)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType);
-
- typedef R(UnboundRunType)(X2);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2));
- }
-};
-
-// Arity 2 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2>
-struct Invoker<2, StorageType, R(X1, X2)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2));
- }
-};
-
-// Arity 3 -> 3.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3>
-struct Invoker<0, StorageType, R(X1, X2, X3)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2, X3);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3));
- }
-};
-
-// Arity 3 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3>
-struct Invoker<1, StorageType, R(X1, X2, X3)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType);
-
- typedef R(UnboundRunType)(X2, X3);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3));
- }
-};
-
-// Arity 3 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3>
-struct Invoker<2, StorageType, R(X1, X2, X3)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X3>::ForwardType);
-
- typedef R(UnboundRunType)(X3);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X3>::ForwardType x3) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType x3)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3));
- }
-};
-
-// Arity 3 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3>
-struct Invoker<3, StorageType, R(X1, X2, X3)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3));
- }
-};
-
-// Arity 4 -> 4.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4>
-struct Invoker<0, StorageType, R(X1, X2, X3, X4)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2, X3, X4);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4));
- }
-};
-
-// Arity 4 -> 3.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4>
-struct Invoker<1, StorageType, R(X1, X2, X3, X4)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType);
-
- typedef R(UnboundRunType)(X2, X3, X4);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4));
- }
-};
-
-// Arity 4 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4>
-struct Invoker<2, StorageType, R(X1, X2, X3, X4)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType);
-
- typedef R(UnboundRunType)(X3, X4);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4));
- }
-};
-
-// Arity 4 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4>
-struct Invoker<3, StorageType, R(X1, X2, X3, X4)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X4>::ForwardType);
-
- typedef R(UnboundRunType)(X4);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X4>::ForwardType x4) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType x4)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4));
- }
-};
-
-// Arity 4 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4>
-struct Invoker<4, StorageType, R(X1, X2, X3, X4)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4));
- }
-};
-
-// Arity 5 -> 5.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2, X3, X4, X5);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 5 -> 4.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType);
-
- typedef R(UnboundRunType)(X2, X3, X4, X5);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 5 -> 3.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType);
-
- typedef R(UnboundRunType)(X3, X4, X5);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 5 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType);
-
- typedef R(UnboundRunType)(X4, X5);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 5 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X5>::ForwardType);
-
- typedef R(UnboundRunType)(X5);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X5>::ForwardType x5) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType x5)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 5 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5>
-struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5));
- }
-};
-
-// Arity 6 -> 6.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 5.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X2, X3, X4, X5, X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 4.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X3, X4, X5, X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 3.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X4, X5, X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X5, X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X6>::ForwardType);
-
- typedef R(UnboundRunType)(X6);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X6>::ForwardType x6) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType x6)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 6 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6>
-struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
- typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- typename Bound6UnwrapTraits::ForwardType x6 =
- Bound6UnwrapTraits::Unwrap(storage->p6_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType,
- typename Bound6UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6));
- }
-};
-
-// Arity 7 -> 7.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X1>::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename CallbackParamTraits<X1>::ForwardType x1,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 6.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X2>::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X2>::ForwardType x2,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 5.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X3>::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X3, X4, X5, X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X3>::ForwardType x3,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 4.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X4>::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X4, X5, X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X4>::ForwardType x4,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 3.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X5>::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X5, X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X5>::ForwardType x5,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 2.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X6>::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X6, X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X6>::ForwardType x6,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 1.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*,
- typename CallbackParamTraits<X7>::ForwardType);
-
- typedef R(UnboundRunType)(X7);
-
- static R Run(BindStateBase* base,
- typename CallbackParamTraits<X7>::ForwardType x7) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
- typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- typename Bound6UnwrapTraits::ForwardType x6 =
- Bound6UnwrapTraits::Unwrap(storage->p6_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType,
- typename Bound6UnwrapTraits::ForwardType,
- typename CallbackParamTraits<X7>::ForwardType x7)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-// Arity 7 -> 0.
-template <typename StorageType, typename R,typename X1, typename X2,
- typename X3, typename X4, typename X5, typename X6, typename X7>
-struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> {
- typedef R(RunType)(BindStateBase*);
-
- typedef R(UnboundRunType)();
-
- static R Run(BindStateBase* base) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
- typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits;
- typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits;
- typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits;
- typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits;
- typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits;
- typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits;
- typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits;
-
- typename Bound1UnwrapTraits::ForwardType x1 =
- Bound1UnwrapTraits::Unwrap(storage->p1_);
- typename Bound2UnwrapTraits::ForwardType x2 =
- Bound2UnwrapTraits::Unwrap(storage->p2_);
- typename Bound3UnwrapTraits::ForwardType x3 =
- Bound3UnwrapTraits::Unwrap(storage->p3_);
- typename Bound4UnwrapTraits::ForwardType x4 =
- Bound4UnwrapTraits::Unwrap(storage->p4_);
- typename Bound5UnwrapTraits::ForwardType x5 =
- Bound5UnwrapTraits::Unwrap(storage->p5_);
- typename Bound6UnwrapTraits::ForwardType x6 =
- Bound6UnwrapTraits::Unwrap(storage->p6_);
- typename Bound7UnwrapTraits::ForwardType x7 =
- Bound7UnwrapTraits::Unwrap(storage->p7_);
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(typename Bound1UnwrapTraits::ForwardType,
- typename Bound2UnwrapTraits::ForwardType,
- typename Bound3UnwrapTraits::ForwardType,
- typename Bound4UnwrapTraits::ForwardType,
- typename Bound5UnwrapTraits::ForwardType,
- typename Bound6UnwrapTraits::ForwardType,
- typename Bound7UnwrapTraits::ForwardType)>
- ::MakeItSo(storage->runnable_, CallbackForward(x1),
- CallbackForward(x2), CallbackForward(x3),
- CallbackForward(x4), CallbackForward(x5),
- CallbackForward(x6), CallbackForward(x7));
- }
-};
-
-
-// BindState<>
-//
-// This stores all the state passed into Bind() and is also where most
-// of the template resolution magic occurs.
-//
-// Runnable is the functor we are binding arguments to.
-// RunType is type of the Run() function that the Invoker<> should use.
-// Normally, this is the same as the RunType of the Runnable, but it can
-// be different if an adapter like IgnoreResult() has been used.
-//
-// BoundArgsType contains the storage type for all the bound arguments by
-// (ab)using a function type.
-template <typename Runnable, typename RunType, typename BoundArgsType>
-struct BindState;
-
-template <typename Runnable, typename RunType>
-struct BindState<Runnable, RunType, void()> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<0, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
- explicit BindState(Runnable runnable) : runnable_(std::move(runnable)) {}
-
- virtual ~BindState() { }
-
- RunnableType runnable_;
-};
-
-template <typename Runnable, typename RunType, typename P1>
-struct BindState<Runnable, RunType, void(P1)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<1, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
-
- BindState(Runnable runnable, P1 p1)
- : runnable_(std::move(runnable)), p1_(std::move(p1)) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2>
-struct BindState<Runnable, RunType, void(P1, P2)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<2, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
-
- BindState(Runnable runnable, P1 p1, P2 p2)
- : runnable_(std::move(runnable)), p1_(std::move(p1)), p2_(std::move(p2)) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2,
- typename P3>
-struct BindState<Runnable, RunType, void(P1, P2, P3)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<3, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
- typedef UnwrapTraits<P3> Bound3UnwrapTraits;
-
- BindState(Runnable runnable, P1 p1, P2 p2, P3 p3)
- : runnable_(std::move(runnable)),
- p1_(std::move(p1)),
- p2_(std::move(p2)),
- p3_(std::move(p3)) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
- P3 p3_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2,
- typename P3, typename P4>
-struct BindState<Runnable, RunType, void(P1, P2, P3,
- P4)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<4, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
- typedef UnwrapTraits<P3> Bound3UnwrapTraits;
- typedef UnwrapTraits<P4> Bound4UnwrapTraits;
-
- BindState(Runnable runnable, P1 p1, P2 p2, const P3& p3, P4 p4)
- : runnable_(std::move(runnable)),
- p1_(std::move(p1)),
- p2_(std::move(p2)),
- p3_(p3),
- p4_(std::move(p4)) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
- P3 p3_;
- P4 p4_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2,
- typename P3, typename P4, typename P5>
-struct BindState<Runnable, RunType, void(P1, P2, P3, P4,
- P5)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<5, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
- typedef UnwrapTraits<P3> Bound3UnwrapTraits;
- typedef UnwrapTraits<P4> Bound4UnwrapTraits;
- typedef UnwrapTraits<P5> Bound5UnwrapTraits;
-
- BindState(Runnable runnable, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
- : runnable_(std::move(runnable)),
- p1_(std::move(p1)),
- p2_(std::move(p2)),
- p3_(std::move(p3)),
- p4_(std::move(p4)),
- p5_(std::move(p5)) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
- P3 p3_;
- P4 p4_;
- P5 p5_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2,
- typename P3, typename P4, typename P5, typename P6>
-struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5,
- P6)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<6, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
- typedef UnwrapTraits<P3> Bound3UnwrapTraits;
- typedef UnwrapTraits<P4> Bound4UnwrapTraits;
- typedef UnwrapTraits<P5> Bound5UnwrapTraits;
- typedef UnwrapTraits<P6> Bound6UnwrapTraits;
-
- BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
- const P4& p4, const P5& p5, const P6& p6)
- : runnable_(runnable),
- p1_(p1),
- p2_(p2),
- p3_(p3),
- p4_(p4),
- p5_(p5),
- p6_(p6) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
- P3 p3_;
- P4 p4_;
- P5 p5_;
- P6 p6_;
-};
-
-template <typename Runnable, typename RunType, typename P1, typename P2,
- typename P3, typename P4, typename P5, typename P6, typename P7>
-struct BindState<Runnable, RunType, void(P1, P2, P3, P4, P5, P6,
- P7)> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<7, BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
- // Convenience typedefs for bound argument types.
- typedef UnwrapTraits<P1> Bound1UnwrapTraits;
- typedef UnwrapTraits<P2> Bound2UnwrapTraits;
- typedef UnwrapTraits<P3> Bound3UnwrapTraits;
- typedef UnwrapTraits<P4> Bound4UnwrapTraits;
- typedef UnwrapTraits<P5> Bound5UnwrapTraits;
- typedef UnwrapTraits<P6> Bound6UnwrapTraits;
- typedef UnwrapTraits<P7> Bound7UnwrapTraits;
-
- BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3,
- const P4& p4, const P5& p5, const P6& p6, const P7& p7)
- : runnable_(runnable),
- p1_(p1),
- p2_(p2),
- p3_(p3),
- p4_(p4),
- p5_(p5),
- p6_(p6),
- p7_(p7) {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
- }
-
- virtual ~BindState() { MaybeRefcount<HasIsMethodTag<Runnable>::value,
- P1>::Release(p1_); }
-
- RunnableType runnable_;
- P1 p1_;
- P2 p2_;
- P3 p3_;
- P4 p4_;
- P5 p5_;
- P6 p6_;
- P7 p7_;
-};
-
-} // namespace internal
-} // namespace kudu
-
-#endif // GUTIL_BIND_INTERNAL_H_
diff --git a/be/src/gutil/bind_internal.h.pump b/be/src/gutil/bind_internal.h.pump
deleted file mode 100644
index 1c8ad615a..000000000
--- a/be/src/gutil/bind_internal.h.pump
+++ /dev/null
@@ -1,464 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$ See comment for MAX_ARITY in gutil/bind.h.pump.
-$var MAX_ARITY = 7
-$range ARITY 0..MAX_ARITY
-
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_BIND_INTERNAL_H_
-#define GUTIL_BIND_INTERNAL_H_
-
-#include "gutil/bind_helpers.h"
-#include "gutil/callback_internal.h"
-#include "gutil/raw_scoped_refptr_mismatch_checker.h"
-#include "gutil/template_util.h"
-
-#if defined(OS_WIN)
-#include "gutil/bind_internal_win.h"
-#endif
-
-// During Chromium import, WeakPtr-related code was removed.
-
-namespace kudu {
-namespace internal {
-
-// See gutil/callback.h for user documentation.
-//
-//
-// CONCEPTS:
-// Runnable -- A type (really a type class) that has a single Run() method
-// and a RunType typedef that corresponds to the type of Run().
-// A Runnable can declare that it should treated like a method
-// call by including a typedef named IsMethod. The value of
-// this typedef is NOT inspected, only the existence. When a
-// Runnable declares itself a method, Bind() will enforce special
-// refcounting + WeakPtr handling semantics for the first
-// parameter which is expected to be an object.
-// Functor -- A copyable type representing something that should be called.
-// All function pointers, Callback<>, and Runnables are functors
-// even if the invocation syntax differs.
-// RunType -- A function type (as opposed to function _pointer_ type) for
-// a Run() function. Usually just a convenience typedef.
-// (Bound)ArgsType -- A function type that is being (ab)used to store the
-// types of set of arguments. The "return" type is always
-// void here. We use this hack so that we do not need
-// a new type name for each arity of type. (eg.,
-// BindState1, BindState2). This makes forward
-// declarations and friending much much easier.
-//
-// Types:
-// RunnableAdapter<> -- Wraps the various "function" pointer types into an
-// object that adheres to the Runnable interface.
-// There are |3*ARITY| RunnableAdapter types.
-// FunctionTraits<> -- Type traits that unwrap a function signature into a
-// a set of easier to use typedefs. Used mainly for
-// compile time asserts.
-// There are |ARITY| FunctionTraits types.
-// ForceVoidReturn<> -- Helper class for translating function signatures to
-// equivalent forms with a "void" return type.
-// There are |ARITY| ForceVoidReturn types.
-// FunctorTraits<> -- Type traits used determine the correct RunType and
-// RunnableType for a Functor. This is where function
-// signature adapters are applied.
-// There are |ARITY| ForceVoidReturn types.
-// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable
-// type class that represents the underlying Functor.
-// There are |O(1)| MakeRunnable types.
-// InvokeHelper<> -- Take a Runnable + arguments and actully invokes it.
-// Handle the differing syntaxes needed for WeakPtr<> support,
-// and for ignoring return values. This is separate from
-// Invoker to avoid creating multiple version of Invoker<>
-// which grows at O(n^2) with the arity.
-// There are |k*ARITY| InvokeHelper types.
-// Invoker<> -- Unwraps the curried parameters and executes the Runnable.
-// There are |(ARITY^2 + ARITY)/2| Invoketypes.
-// BindState<> -- Stores the curried parameters, and is the main entry point
-// into the Bind() system, doing most of the type resolution.
-// There are ARITY BindState types.
-
-// RunnableAdapter<>
-//
-// The RunnableAdapter<> templates provide a uniform interface for invoking
-// a function pointer, method pointer, or const method pointer. The adapter
-// exposes a Run() method with an appropriate signature. Using this wrapper
-// allows for writing code that supports all three pointer types without
-// undue repetition. Without it, a lot of code would need to be repeated 3
-// times.
-//
-// For method pointers and const method pointers the first argument to Run()
-// is considered to be the received of the method. This is similar to STL's
-// mem_fun().
-//
-// This class also exposes a RunType typedef that is the function type of the
-// Run() function.
-//
-// If and only if the wrapper contains a method or const method pointer, an
-// IsMethod typedef is exposed. The existence of this typedef (NOT the value)
-// marks that the wrapper should be considered a method wrapper.
-
-template <typename Functor>
-class RunnableAdapter;
-
-$for ARITY [[
-$range ARG 1..ARITY
-
-// Function: Arity $(ARITY).
-template <typename R[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
-class RunnableAdapter<R(*)($for ARG , [[A$(ARG)]])> {
- public:
- typedef R (RunType)($for ARG , [[A$(ARG)]]);
-
- explicit RunnableAdapter(R(*function)($for ARG , [[A$(ARG)]]))
- : function_(function) {
- }
-
- R Run($for ARG , [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return function_($for ARG , [[CallbackForward(a$(ARG))]]);
- }
-
- private:
- R (*function_)($for ARG , [[A$(ARG)]]);
-};
-
-// Method: Arity $(ARITY).
-template <typename R, typename T[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
-class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]])> {
- public:
- typedef R (RunType)(T*[[]]
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]]))
- : method_(method) {
- }
-
- R Run(T* object[[]]
-$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]);
- }
-
- private:
- R (T::*method_)($for ARG , [[A$(ARG)]]);
-};
-
-// Const Method: Arity $(ARITY).
-template <typename R, typename T[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
-class RunnableAdapter<R(T::*)($for ARG , [[A$(ARG)]]) const> {
- public:
- typedef R (RunType)(const T*[[]]
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG)]]);
- typedef base::true_type IsMethod;
-
- explicit RunnableAdapter(R(T::*method)($for ARG , [[A$(ARG)]]) const)
- : method_(method) {
- }
-
- R Run(const T* object[[]]
-$if ARITY > 0[[, ]] $for ARG, [[typename CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) {
- return (object->*method_)($for ARG , [[CallbackForward(a$(ARG))]]);
- }
-
- private:
- R (T::*method_)($for ARG , [[A$(ARG)]]) const;
-};
-
-]] $$ for ARITY
-
-
-// FunctionTraits<>
-//
-// Breaks a function signature apart into typedefs for easier introspection.
-template <typename Sig>
-struct FunctionTraits;
-
-$for ARITY [[
-$range ARG 1..ARITY
-
-template <typename R[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
-struct FunctionTraits<R($for ARG , [[A$(ARG)]])> {
- typedef R ReturnType;
-$for ARG [[
-
- typedef A$(ARG) A$(ARG)Type;
-]]
-
-};
-
-]]
-
-
-// ForceVoidReturn<>
-//
-// Set of templates that support forcing the function return type to void.
-template <typename Sig>
-struct ForceVoidReturn;
-
-$for ARITY [[
-$range ARG 1..ARITY
-
-template <typename R[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename A$(ARG)]]>
-struct ForceVoidReturn<R($for ARG , [[A$(ARG)]])> {
- typedef void(RunType)($for ARG , [[A$(ARG)]]);
-};
-
-]] $$ for ARITY
-
-
-// FunctorTraits<>
-//
-// See description at top of file.
-template <typename T>
-struct FunctorTraits {
- typedef RunnableAdapter<T> RunnableType;
- typedef typename RunnableType::RunType RunType;
-};
-
-template <typename T>
-struct FunctorTraits<IgnoreResultHelper<T> > {
- typedef typename FunctorTraits<T>::RunnableType RunnableType;
- typedef typename ForceVoidReturn<
- typename RunnableType::RunType>::RunType RunType;
-};
-
-template <typename T>
-struct FunctorTraits<Callback<T> > {
- typedef Callback<T> RunnableType;
- typedef typename Callback<T>::RunType RunType;
-};
-
-
-// MakeRunnable<>
-//
-// Converts a passed in functor to a RunnableType using type inference.
-
-template <typename T>
-typename FunctorTraits<T>::RunnableType MakeRunnable(const T& t) {
- return RunnableAdapter<T>(t);
-}
-
-template <typename T>
-typename FunctorTraits<T>::RunnableType
-MakeRunnable(const IgnoreResultHelper<T>& t) {
- return MakeRunnable(t.functor_);
-}
-
-template <typename T>
-const typename FunctorTraits<Callback<T> >::RunnableType&
-MakeRunnable(const Callback<T>& t) {
- DCHECK(!t.is_null());
- return t;
-}
-
-
-// InvokeHelper<>
-//
-// There are 3 logical InvokeHelper<> specializations: normal, void-return,
-// WeakCalls.
-//
-// The normal type just calls the underlying runnable.
-//
-// We need a InvokeHelper to handle void return types in order to support
-// IgnoreResult(). Normally, if the Runnable's RunType had a void return,
-// the template system would just accept "return functor.Run()" ignoring
-// the fact that a void function is being used with return. This piece of
-// sugar breaks though when the Runnable's RunType is not void. Thus, we
-// need a partial specialization to change the syntax to drop the "return"
-// from the invocation call.
-//
-// WeakCalls similarly need special syntax that is applied to the first
-// argument to check if they should no-op themselves.
-template <bool IsWeakCall, typename ReturnType, typename Runnable,
- typename ArgsType>
-struct InvokeHelper;
-
-$for ARITY [[
-$range ARG 1..ARITY
-$range WEAKCALL_ARG 2..ARITY
-
-template <typename ReturnType, typename Runnable[[]]
-$if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]>
-struct InvokeHelper<false, ReturnType, Runnable,
- void($for ARG , [[A$(ARG)]])> {
- static ReturnType MakeItSo(Runnable runnable[[]]
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) {
- return runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]);
- }
-};
-
-template <typename Runnable[[]]
-$if ARITY > 0 [[,]] $for ARG , [[typename A$(ARG)]]>
-struct InvokeHelper<false, void, Runnable,
- void($for ARG , [[A$(ARG)]])> {
- static void MakeItSo(Runnable runnable[[]]
-$if ARITY > 0[[, ]] $for ARG , [[A$(ARG) a$(ARG)]]) {
- runnable.Run($for ARG , [[CallbackForward(a$(ARG))]]);
- }
-};
-
-]] $$ for ARITY
-
-// Invoker<>
-//
-// See description at the top of the file.
-template <int NumBound, typename Storage, typename RunType>
-struct Invoker;
-
-$for ARITY [[
-
-$$ Number of bound arguments.
-$range BOUND 0..ARITY
-$for BOUND [[
-
-$var UNBOUND = ARITY - BOUND
-$range ARG 1..ARITY
-$range BOUND_ARG 1..BOUND
-$range UNBOUND_ARG (ARITY - UNBOUND + 1)..ARITY
-
-// Arity $(ARITY) -> $(UNBOUND).
-template <typename StorageType, typename R[[]]
-$if ARITY > 0 [[,]][[]]
-$for ARG , [[typename X$(ARG)]]>
-struct Invoker<$(BOUND), StorageType, R($for ARG , [[X$(ARG)]])> {
- typedef R(RunType)(BindStateBase*[[]]
-$if UNBOUND != 0 [[, ]]
-$for UNBOUND_ARG , [[typename CallbackParamTraits<X$(UNBOUND_ARG)>::ForwardType]]);
-
- typedef R(UnboundRunType)($for UNBOUND_ARG , [[X$(UNBOUND_ARG)]]);
-
- static R Run(BindStateBase* base[[]]
-$if UNBOUND != 0 [[, ]][[]]
-$for UNBOUND_ARG , [[
-typename CallbackParamTraits<X$(UNBOUND_ARG)>::ForwardType x$(UNBOUND_ARG)
-]][[]]
-) {
- StorageType* storage = static_cast<StorageType*>(base);
-
- // Local references to make debugger stepping easier. If in a debugger,
- // you really want to warp ahead and step through the
- // InvokeHelper<>::MakeItSo() call below.
-$for BOUND_ARG
-[[
-
- typedef typename StorageType::Bound$(BOUND_ARG)UnwrapTraits Bound$(BOUND_ARG)UnwrapTraits;
-]]
-
-
-$for BOUND_ARG
-[[
-
- typename Bound$(BOUND_ARG)UnwrapTraits::ForwardType x$(BOUND_ARG) =
- Bound$(BOUND_ARG)UnwrapTraits::Unwrap(storage->p$(BOUND_ARG)_);
-]]
-
- return InvokeHelper<StorageType::IsWeakCall::value, R,
- typename StorageType::RunnableType,
- void(
-$for BOUND_ARG , [[
-typename Bound$(BOUND_ARG)UnwrapTraits::ForwardType
-]]
-
-$if UNBOUND > 0 [[$if BOUND > 0 [[, ]]]][[]]
-
-$for UNBOUND_ARG , [[
-typename CallbackParamTraits<X$(UNBOUND_ARG)>::ForwardType x$(UNBOUND_ARG)
-]]
-)>
- ::MakeItSo(storage->runnable_
-$if ARITY > 0[[, ]] $for ARG , [[CallbackForward(x$(ARG))]]);
- }
-};
-
-]] $$ for BOUND
-]] $$ for ARITY
-
-
-// BindState<>
-//
-// This stores all the state passed into Bind() and is also where most
-// of the template resolution magic occurs.
-//
-// Runnable is the functor we are binding arguments to.
-// RunType is type of the Run() function that the Invoker<> should use.
-// Normally, this is the same as the RunType of the Runnable, but it can
-// be different if an adapter like IgnoreResult() has been used.
-//
-// BoundArgsType contains the storage type for all the bound arguments by
-// (ab)using a function type.
-template <typename Runnable, typename RunType, typename BoundArgsType>
-struct BindState;
-
-$for ARITY [[
-$range ARG 1..ARITY
-
-template <typename Runnable, typename RunType[[]]
-$if ARITY > 0[[, ]] $for ARG , [[typename P$(ARG)]]>
-struct BindState<Runnable, RunType, void($for ARG , [[P$(ARG)]])> : public BindStateBase {
- typedef Runnable RunnableType;
-
- typedef base::false_type IsWeakCall;
-
- typedef Invoker<$(ARITY), BindState, RunType> InvokerType;
- typedef typename InvokerType::UnboundRunType UnboundRunType;
-
-$if ARITY > 0 [[
-
- // Convenience typedefs for bound argument types.
-
-$for ARG [[
- typedef UnwrapTraits<P$(ARG)> Bound$(ARG)UnwrapTraits;
-
-]] $$ for ARG
-
-
-]] $$ if ARITY > 0
-
-$$ The extra [[ ]] is needed to massage spacing. Silly pump.py.
-[[ ]]$if ARITY == 0 [[explicit ]]BindState(const Runnable& runnable
-$if ARITY > 0 [[, ]] $for ARG , [[const P$(ARG)& p$(ARG)]])
- : runnable_(runnable)[[]]
-$if ARITY == 0 [[
- {
-
-]] $else [[
-, $for ARG , [[
-
- p$(ARG)_(p$(ARG))
-]] {
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::AddRef(p1_);
-
-]]
- }
-
- virtual ~BindState() {
-$if ARITY > 0 [[
- MaybeRefcount<HasIsMethodTag<Runnable>::value, P1>::Release(p1_);
-]]
- }
-
- RunnableType runnable_;
-
-$for ARG [[
- P$(ARG) p$(ARG)_;
-
-]]
-};
-
-]] $$ for ARITY
-
-} // namespace internal
-} // namespace kudu
-
-#endif // GUTIL_BIND_INTERNAL_H_
diff --git a/be/src/gutil/callback.h b/be/src/gutil/callback.h
deleted file mode 100644
index b0b29b203..000000000
--- a/be/src/gutil/callback.h
+++ /dev/null
@@ -1,765 +0,0 @@
-// This file was GENERATED by command:
-// pump.py callback.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_CALLBACK_H_
-#define GUTIL_CALLBACK_H_
-
-#include "gutil/callback_forward.h"
-#include "gutil/callback_internal.h"
-#include "gutil/template_util.h"
-
-// NOTE: Header files that do not require the full definition of Callback or
-// Closure should #include "gutil/callback_forward.h" instead of this file.
-
-// -----------------------------------------------------------------------------
-// Introduction
-// -----------------------------------------------------------------------------
-//
-// The templated Callback class is a generalized function object. Together
-// with the Bind() function in bind.h, they provide a type-safe method for
-// performing partial application of functions.
-//
-// Partial application (or "currying") is the process of binding a subset of
-// a function's arguments to produce another function that takes fewer
-// arguments. This can be used to pass around a unit of delayed execution,
-// much like lexical closures are used in other languages. For example, it
-// is used in Chromium code to schedule tasks on different MessageLoops.
-//
-// A callback with no unbound input parameters (kudu::Callback<void(void)>)
-// is called a kudu::Closure. Note that this is NOT the same as what other
-// languages refer to as a closure -- it does not retain a reference to its
-// enclosing environment.
-//
-// MEMORY MANAGEMENT AND PASSING
-//
-// The Callback objects themselves should be passed by const-reference, and
-// stored by copy. They internally store their state via a refcounted class
-// and thus do not need to be deleted.
-//
-// The reason to pass via a const-reference is to avoid unnecessary
-// AddRef/Release pairs to the internal state.
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for basic stuff
-// -----------------------------------------------------------------------------
-//
-// BINDING A BARE FUNCTION
-//
-// int Return5() { return 5; }
-// kudu::Callback<int(void)> func_cb = kudu::Bind(&Return5);
-// LOG(INFO) << func_cb.Run(); // Prints 5.
-//
-// BINDING A CLASS METHOD
-//
-// The first argument to bind is the member function to call, the second is
-// the object on which to call it.
-//
-// class Ref : public kudu::RefCountedThreadSafe<Ref> {
-// public:
-// int Foo() { return 3; }
-// void PrintBye() { LOG(INFO) << "bye."; }
-// };
-// scoped_refptr<Ref> ref = new Ref();
-// kudu::Callback<void(void)> ref_cb = kudu::Bind(&Ref::Foo, ref);
-// LOG(INFO) << ref_cb.Run(); // Prints out 3.
-//
-// By default the object must support RefCounted or you will get a compiler
-// error. If you're passing between threads, be sure it's
-// RefCountedThreadSafe! See "Advanced binding of member functions" below if
-// you don't want to use reference counting.
-//
-// RUNNING A CALLBACK
-//
-// Callbacks can be run with their "Run" method, which has the same
-// signature as the template argument to the callback.
-//
-// void DoSomething(const kudu::Callback<void(int, std::string)>& callback) {
-// callback.Run(5, "hello");
-// }
-//
-// Callbacks can be run more than once (they don't get deleted or marked when
-// run). However, this precludes using kudu::Passed (see below).
-//
-// void DoSomething(const kudu::Callback<double(double)>& callback) {
-// double myresult = callback.Run(3.14159);
-// myresult += callback.Run(2.71828);
-// }
-//
-// PASSING UNBOUND INPUT PARAMETERS
-//
-// Unbound parameters are specified at the time a callback is Run(). They are
-// specified in the Callback template type:
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(int, const std::string&)> cb = kudu::Bind(&MyFunc);
-// cb.Run(23, "hello, world");
-//
-// PASSING BOUND INPUT PARAMETERS
-//
-// Bound parameters are specified when you create the callback as arguments
-// to Bind(). They will be passed to the function and the Run()ner of the
-// callback doesn't see those values or even know that the function it's
-// calling.
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(void)> cb = kudu::Bind(&MyFunc, 23, "hello world");
-// cb.Run();
-//
-// A callback with no unbound input parameters (kudu::Callback<void(void)>)
-// is called a kudu::Closure. So we could have also written:
-//
-// kudu::Closure cb = kudu::Bind(&MyFunc, 23, "hello world");
-//
-// When calling member functions, bound parameters just go after the object
-// pointer.
-//
-// kudu::Closure cb = kudu::Bind(&MyClass::MyFunc, this, 23, "hello world");
-//
-// PARTIAL BINDING OF PARAMETERS
-//
-// You can specify some parameters when you create the callback, and specify
-// the rest when you execute the callback.
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(const std::string&)> cb = kudu::Bind(&MyFunc, 23);
-// cb.Run("hello world");
-//
-// When calling a function bound parameters are first, followed by unbound
-// parameters.
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for advanced binding
-// -----------------------------------------------------------------------------
-//
-// BINDING A CLASS METHOD WITH WEAK POINTERS
-//
-// kudu::Bind(&MyClass::Foo, GetWeakPtr());
-//
-// The callback will not be issued if the object is destroyed at the time
-// it's issued. DANGER: weak pointers are not threadsafe, so don't use this
-// when passing between threads!
-//
-// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT
-//
-// kudu::Bind(&MyClass::Foo, kudu::Unretained(this));
-//
-// This disables all lifetime management on the object. You're responsible
-// for making sure the object is alive at the time of the call. You break it,
-// you own it!
-//
-// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS
-//
-// MyClass* myclass = new MyClass;
-// kudu::Bind(&MyClass::Foo, kudu::Owned(myclass));
-//
-// The object will be deleted when the callback is destroyed, even if it's
-// not run (like if you post a task during shutdown). Potentially useful for
-// "fire and forget" cases.
-//
-// IGNORING RETURN VALUES
-//
-// Sometimes you want to call a function that returns a value in a callback
-// that doesn't expect a return value.
-//
-// int DoSomething(int arg) { cout << arg << endl; }
-// kudu::Callback<void<int>) cb =
-// kudu::Bind(kudu::IgnoreResult(&DoSomething));
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for binding parameters to Bind()
-// -----------------------------------------------------------------------------
-//
-// Bound parameters are specified as arguments to Bind() and are passed to the
-// function. A callback with no parameters or no unbound parameters is called a
-// Closure (kudu::Callback<void(void)> and kudu::Closure are the same thing).
-//
-// PASSING PARAMETERS OWNED BY THE CALLBACK
-//
-// void Foo(int* arg) { cout << *arg << endl; }
-// int* pn = new int(1);
-// kudu::Closure foo_callback = kudu::Bind(&foo, kudu::Owned(pn));
-//
-// The parameter will be deleted when the callback is destroyed, even if it's
-// not run (like if you post a task during shutdown).
-//
-// PASSING PARAMETERS AS A scoped_ptr
-//
-// void TakesOwnership(scoped_ptr<Foo> arg) {}
-// scoped_ptr<Foo> f(new Foo);
-// // f becomes null during the following call.
-// kudu::Closure cb = kudu::Bind(&TakesOwnership, kudu::Passed(&f));
-//
-// Ownership of the parameter will be with the callback until the it is run,
-// when ownership is passed to the callback function. This means the callback
-// can only be run once. If the callback is never run, it will delete the
-// object when it's destroyed.
-//
-// PASSING PARAMETERS AS A scoped_refptr
-//
-// void TakesOneRef(scoped_refptr<Foo> arg) {}
-// scoped_refptr<Foo> f(new Foo)
-// kudu::Closure cb = kudu::Bind(&TakesOneRef, f);
-//
-// This should "just work." The closure will take a reference as long as it
-// is alive, and another reference will be taken for the called function.
-//
-// PASSING PARAMETERS BY REFERENCE
-//
-// void foo(int arg) { cout << arg << endl }
-// int n = 1;
-// kudu::Closure has_ref = kudu::Bind(&foo, kudu::ConstRef(n));
-// n = 2;
-// has_ref.Run(); // Prints "2"
-//
-// Normally parameters are copied in the closure. DANGER: ConstRef stores a
-// const reference instead, referencing the original parameter. This means
-// that you must ensure the object outlives the callback!
-//
-//
-// -----------------------------------------------------------------------------
-// Implementation notes
-// -----------------------------------------------------------------------------
-//
-// WHERE IS THIS DESIGN FROM:
-//
-// The design Callback and Bind is heavily influenced by C++'s
-// tr1::function/tr1::bind, and by the "Google Callback" system used inside
-// Google.
-//
-//
-// HOW THE IMPLEMENTATION WORKS:
-//
-// There are three main components to the system:
-// 1) The Callback classes.
-// 2) The Bind() functions.
-// 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
-//
-// The Callback classes represent a generic function pointer. Internally,
-// it stores a refcounted piece of state that represents the target function
-// and all its bound parameters. Each Callback specialization has a templated
-// constructor that takes an BindState<>*. In the context of the constructor,
-// the static type of this BindState<> pointer uniquely identifies the
-// function it is representing, all its bound parameters, and a Run() method
-// that is capable of invoking the target.
-//
-// Callback's constructor takes the BindState<>* that has the full static type
-// and erases the target function type as well as the types of the bound
-// parameters. It does this by storing a pointer to the specific Run()
-// function, and upcasting the state of BindState<>* to a
-// BindStateBase*. This is safe as long as this BindStateBase pointer
-// is only used with the stored Run() pointer.
-//
-// To BindState<> objects are created inside the Bind() functions.
-// These functions, along with a set of internal templates, are responsible for
-//
-// - Unwrapping the function signature into return type, and parameters
-// - Determining the number of parameters that are bound
-// - Creating the BindState storing the bound parameters
-// - Performing compile-time asserts to avoid error-prone behavior
-// - Returning an Callback<> with an arity matching the number of unbound
-// parameters and that knows the correct refcounting semantics for the
-// target object if we are binding a method.
-//
-// The Bind functions do the above using type-inference, and template
-// specializations.
-//
-// By default Bind() will store copies of all bound parameters, and attempt
-// to refcount a target object if the function being bound is a class method.
-// These copies are created even if the function takes parameters as const
-// references. (Binding to non-const references is forbidden, see bind.h.)
-//
-// To change this behavior, we introduce a set of argument wrappers
-// (e.g., Unretained(), and ConstRef()). These are simple container templates
-// that are passed by value, and wrap a pointer to argument. See the
-// file-level comment in kudu/gutil/bind_helpers.h for more info.
-//
-// These types are passed to the Unwrap() functions, and the MaybeRefcount()
-// functions respectively to modify the behavior of Bind(). The Unwrap()
-// and MaybeRefcount() functions change behavior by doing partial
-// specialization based on whether or not a parameter is a wrapper type.
-//
-// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
-//
-//
-// WHY NOT TR1 FUNCTION/BIND?
-//
-// Direct use of tr1::function and tr1::bind was considered, but ultimately
-// rejected because of the number of copy constructors invocations involved
-// in the binding of arguments during construction, and the forwarding of
-// arguments during invocation. These copies will no longer be an issue in
-// C++0x because C++0x will support rvalue reference allowing for the compiler
-// to avoid these copies. However, waiting for C++0x is not an option.
-//
-// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
-// tr1::bind call itself will invoke a non-trivial copy constructor three times
-// for each bound parameter. Also, each when passing a tr1::function, each
-// bound argument will be copied again.
-//
-// In addition to the copies taken at binding and invocation, copying a
-// tr1::function causes a copy to be made of all the bound parameters and
-// state.
-//
-// Furthermore, in Chromium, it is desirable for the Callback to take a
-// reference on a target object when representing a class method call. This
-// is not supported by tr1.
-//
-// Lastly, tr1::function and tr1::bind has a more general and flexible API.
-// This includes things like argument reordering by use of
-// tr1::bind::placeholder, support for non-const reference parameters, and some
-// limited amount of subtyping of the tr1::function object (e.g.,
-// tr1::function<int(int)> is convertible to tr1::function<void(int)>).
-//
-// These are not features that are required in Chromium. Some of them, such as
-// allowing for reference parameters, and subtyping of functions, may actually
-// become a source of errors. Removing support for these features actually
-// allows for a simpler implementation, and a terser Currying API.
-//
-//
-// WHY NOT GOOGLE CALLBACKS?
-//
-// The Google callback system also does not support refcounting. Furthermore,
-// its implementation has a number of strange edge cases with respect to type
-// conversion of its arguments. In particular, the argument's constness must
-// at times match exactly the function signature, or the type-inference might
-// break. Given the above, writing a custom solution was easier.
-//
-//
-// MISSING FUNCTIONALITY
-// - Invoking the return of Bind. Bind(&foo).Run() does not work;
-// - Binding arrays to functions that take a non-const pointer.
-// Example:
-// void Foo(const char* ptr);
-// void Bar(char* ptr);
-// Bind(&Foo, "test");
-// Bind(&Bar, "test"); // This fails because ptr is not const.
-
-namespace kudu {
-
-// First, we forward declare the Callback class template. This informs the
-// compiler that the template only has 1 type parameter which is the function
-// signature that the Callback is representing.
-//
-// After this, create template specializations for 0-7 parameters. Note that
-// even though the template typelist grows, the specialization still
-// only has one type: the function signature.
-//
-// If you are thinking of forward declaring Callback in your own header file,
-// please include "base/callback_forward.h" instead.
-template <typename Sig>
-class Callback;
-
-namespace internal {
-template <typename Runnable, typename RunType, typename BoundArgsType>
-struct BindState;
-} // namespace internal
-
-template <typename R>
-class Callback<R(void)> : public internal::CallbackBase {
- public:
- typedef R(RunType)();
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run() const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get());
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*);
-
-};
-
-template <typename R, typename A1>
-class Callback<R(A1)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2>
-class Callback<R(A1, A2)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2, typename A3>
-class Callback<R(A1, A2, A3)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2, A3);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2),
- internal::CallbackForward(a3));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType,
- typename internal::CallbackParamTraits<A3>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4>
-class Callback<R(A1, A2, A3, A4)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2, A3, A4);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2),
- internal::CallbackForward(a3),
- internal::CallbackForward(a4));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType,
- typename internal::CallbackParamTraits<A3>::ForwardType,
- typename internal::CallbackParamTraits<A4>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5>
-class Callback<R(A1, A2, A3, A4, A5)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2, A3, A4, A5);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2),
- internal::CallbackForward(a3),
- internal::CallbackForward(a4),
- internal::CallbackForward(a5));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType,
- typename internal::CallbackParamTraits<A3>::ForwardType,
- typename internal::CallbackParamTraits<A4>::ForwardType,
- typename internal::CallbackParamTraits<A5>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6>
-class Callback<R(A1, A2, A3, A4, A5, A6)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2, A3, A4, A5, A6);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5,
- typename internal::CallbackParamTraits<A6>::ForwardType a6) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2),
- internal::CallbackForward(a3),
- internal::CallbackForward(a4),
- internal::CallbackForward(a5),
- internal::CallbackForward(a6));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType,
- typename internal::CallbackParamTraits<A3>::ForwardType,
- typename internal::CallbackParamTraits<A4>::ForwardType,
- typename internal::CallbackParamTraits<A5>::ForwardType,
- typename internal::CallbackParamTraits<A6>::ForwardType);
-
-};
-
-template <typename R, typename A1, typename A2, typename A3, typename A4,
- typename A5, typename A6, typename A7>
-class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public internal::CallbackBase {
- public:
- typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5,
- typename internal::CallbackParamTraits<A6>::ForwardType a6,
- typename internal::CallbackParamTraits<A7>::ForwardType a7) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get(), internal::CallbackForward(a1),
- internal::CallbackForward(a2),
- internal::CallbackForward(a3),
- internal::CallbackForward(a4),
- internal::CallbackForward(a5),
- internal::CallbackForward(a6),
- internal::CallbackForward(a7));
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*,
- typename internal::CallbackParamTraits<A1>::ForwardType,
- typename internal::CallbackParamTraits<A2>::ForwardType,
- typename internal::CallbackParamTraits<A3>::ForwardType,
- typename internal::CallbackParamTraits<A4>::ForwardType,
- typename internal::CallbackParamTraits<A5>::ForwardType,
- typename internal::CallbackParamTraits<A6>::ForwardType,
- typename internal::CallbackParamTraits<A7>::ForwardType);
-
-};
-
-
-// Syntactic sugar to make Callbacks<void(void)> easier to declare since it
-// will be used in a lot of APIs with delayed execution.
-typedef Callback<void(void)> Closure;
-
-} // namespace kudu
-
-#endif // GUTIL_CALLBACK_H
diff --git a/be/src/gutil/callback.h.pump b/be/src/gutil/callback.h.pump
deleted file mode 100644
index b96c6c944..000000000
--- a/be/src/gutil/callback.h.pump
+++ /dev/null
@@ -1,436 +0,0 @@
-$$ This is a pump file for generating file templates. Pump is a python
-$$ script that is part of the Google Test suite of utilities. Description
-$$ can be found here:
-$$
-$$ http://code.google.com/p/googletest/wiki/PumpManual
-$$
-
-$$ See comment for MAX_ARITY in gutil/bind.h.pump.
-$var MAX_ARITY = 7
-
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_CALLBACK_H_
-#define GUTIL_CALLBACK_H_
-
-#include "gutil/callback_forward.h"
-#include "gutil/callback_internal.h"
-#include "gutil/template_util.h"
-
-// NOTE: Header files that do not require the full definition of Callback or
-// Closure should #include "gutil/callback_forward.h" instead of this file.
-
-// -----------------------------------------------------------------------------
-// Introduction
-// -----------------------------------------------------------------------------
-//
-// The templated Callback class is a generalized function object. Together
-// with the Bind() function in bind.h, they provide a type-safe method for
-// performing partial application of functions.
-//
-// Partial application (or "currying") is the process of binding a subset of
-// a function's arguments to produce another function that takes fewer
-// arguments. This can be used to pass around a unit of delayed execution,
-// much like lexical closures are used in other languages. For example, it
-// is used in Chromium code to schedule tasks on different MessageLoops.
-//
-// A callback with no unbound input parameters (kudu::Callback<void(void)>)
-// is called a kudu::Closure. Note that this is NOT the same as what other
-// languages refer to as a closure -- it does not retain a reference to its
-// enclosing environment.
-//
-// MEMORY MANAGEMENT AND PASSING
-//
-// The Callback objects themselves should be passed by const-reference, and
-// stored by copy. They internally store their state via a refcounted class
-// and thus do not need to be deleted.
-//
-// The reason to pass via a const-reference is to avoid unnecessary
-// AddRef/Release pairs to the internal state.
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for basic stuff
-// -----------------------------------------------------------------------------
-//
-// BINDING A BARE FUNCTION
-//
-// int Return5() { return 5; }
-// kudu::Callback<int(void)> func_cb = kudu::Bind(&Return5);
-// LOG(INFO) << func_cb.Run(); // Prints 5.
-//
-// BINDING A CLASS METHOD
-//
-// The first argument to bind is the member function to call, the second is
-// the object on which to call it.
-//
-// class Ref : public kudu::RefCountedThreadSafe<Ref> {
-// public:
-// int Foo() { return 3; }
-// void PrintBye() { LOG(INFO) << "bye."; }
-// };
-// scoped_refptr<Ref> ref = new Ref();
-// kudu::Callback<void(void)> ref_cb = kudu::Bind(&Ref::Foo, ref);
-// LOG(INFO) << ref_cb.Run(); // Prints out 3.
-//
-// By default the object must support RefCounted or you will get a compiler
-// error. If you're passing between threads, be sure it's
-// RefCountedThreadSafe! See "Advanced binding of member functions" below if
-// you don't want to use reference counting.
-//
-// RUNNING A CALLBACK
-//
-// Callbacks can be run with their "Run" method, which has the same
-// signature as the template argument to the callback.
-//
-// void DoSomething(const kudu::Callback<void(int, std::string)>& callback) {
-// callback.Run(5, "hello");
-// }
-//
-// Callbacks can be run more than once (they don't get deleted or marked when
-// run). However, this precludes using kudu::Passed (see below).
-//
-// void DoSomething(const kudu::Callback<double(double)>& callback) {
-// double myresult = callback.Run(3.14159);
-// myresult += callback.Run(2.71828);
-// }
-//
-// PASSING UNBOUND INPUT PARAMETERS
-//
-// Unbound parameters are specified at the time a callback is Run(). They are
-// specified in the Callback template type:
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(int, const std::string&)> cb = kudu::Bind(&MyFunc);
-// cb.Run(23, "hello, world");
-//
-// PASSING BOUND INPUT PARAMETERS
-//
-// Bound parameters are specified when you create the callback as arguments
-// to Bind(). They will be passed to the function and the Run()ner of the
-// callback doesn't see those values or even know that the function it's
-// calling.
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(void)> cb = kudu::Bind(&MyFunc, 23, "hello world");
-// cb.Run();
-//
-// A callback with no unbound input parameters (kudu::Callback<void(void)>)
-// is called a kudu::Closure. So we could have also written:
-//
-// kudu::Closure cb = kudu::Bind(&MyFunc, 23, "hello world");
-//
-// When calling member functions, bound parameters just go after the object
-// pointer.
-//
-// kudu::Closure cb = kudu::Bind(&MyClass::MyFunc, this, 23, "hello world");
-//
-// PARTIAL BINDING OF PARAMETERS
-//
-// You can specify some parameters when you create the callback, and specify
-// the rest when you execute the callback.
-//
-// void MyFunc(int i, const std::string& str) {}
-// kudu::Callback<void(const std::string&)> cb = kudu::Bind(&MyFunc, 23);
-// cb.Run("hello world");
-//
-// When calling a function bound parameters are first, followed by unbound
-// parameters.
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for advanced binding
-// -----------------------------------------------------------------------------
-//
-// BINDING A CLASS METHOD WITH WEAK POINTERS
-//
-// kudu::Bind(&MyClass::Foo, GetWeakPtr());
-//
-// The callback will not be issued if the object is destroyed at the time
-// it's issued. DANGER: weak pointers are not threadsafe, so don't use this
-// when passing between threads!
-//
-// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT
-//
-// kudu::Bind(&MyClass::Foo, kudu::Unretained(this));
-//
-// This disables all lifetime management on the object. You're responsible
-// for making sure the object is alive at the time of the call. You break it,
-// you own it!
-//
-// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS
-//
-// MyClass* myclass = new MyClass;
-// kudu::Bind(&MyClass::Foo, kudu::Owned(myclass));
-//
-// The object will be deleted when the callback is destroyed, even if it's
-// not run (like if you post a task during shutdown). Potentially useful for
-// "fire and forget" cases.
-//
-// IGNORING RETURN VALUES
-//
-// Sometimes you want to call a function that returns a value in a callback
-// that doesn't expect a return value.
-//
-// int DoSomething(int arg) { cout << arg << endl; }
-// kudu::Callback<void<int>) cb =
-// kudu::Bind(kudu::IgnoreResult(&DoSomething));
-//
-//
-// -----------------------------------------------------------------------------
-// Quick reference for binding parameters to Bind()
-// -----------------------------------------------------------------------------
-//
-// Bound parameters are specified as arguments to Bind() and are passed to the
-// function. A callback with no parameters or no unbound parameters is called a
-// Closure (kudu::Callback<void(void)> and kudu::Closure are the same thing).
-//
-// PASSING PARAMETERS OWNED BY THE CALLBACK
-//
-// void Foo(int* arg) { cout << *arg << endl; }
-// int* pn = new int(1);
-// kudu::Closure foo_callback = kudu::Bind(&foo, kudu::Owned(pn));
-//
-// The parameter will be deleted when the callback is destroyed, even if it's
-// not run (like if you post a task during shutdown).
-//
-// PASSING PARAMETERS AS A scoped_ptr
-//
-// void TakesOwnership(scoped_ptr<Foo> arg) {}
-// scoped_ptr<Foo> f(new Foo);
-// // f becomes null during the following call.
-// kudu::Closure cb = kudu::Bind(&TakesOwnership, kudu::Passed(&f));
-//
-// Ownership of the parameter will be with the callback until the it is run,
-// when ownership is passed to the callback function. This means the callback
-// can only be run once. If the callback is never run, it will delete the
-// object when it's destroyed.
-//
-// PASSING PARAMETERS AS A scoped_refptr
-//
-// void TakesOneRef(scoped_refptr<Foo> arg) {}
-// scoped_refptr<Foo> f(new Foo)
-// kudu::Closure cb = kudu::Bind(&TakesOneRef, f);
-//
-// This should "just work." The closure will take a reference as long as it
-// is alive, and another reference will be taken for the called function.
-//
-// PASSING PARAMETERS BY REFERENCE
-//
-// void foo(int arg) { cout << arg << endl }
-// int n = 1;
-// kudu::Closure has_ref = kudu::Bind(&foo, kudu::ConstRef(n));
-// n = 2;
-// has_ref.Run(); // Prints "2"
-//
-// Normally parameters are copied in the closure. DANGER: ConstRef stores a
-// const reference instead, referencing the original parameter. This means
-// that you must ensure the object outlives the callback!
-//
-//
-// -----------------------------------------------------------------------------
-// Implementation notes
-// -----------------------------------------------------------------------------
-//
-// WHERE IS THIS DESIGN FROM:
-//
-// The design Callback and Bind is heavily influenced by C++'s
-// tr1::function/tr1::bind, and by the "Google Callback" system used inside
-// Google.
-//
-//
-// HOW THE IMPLEMENTATION WORKS:
-//
-// There are three main components to the system:
-// 1) The Callback classes.
-// 2) The Bind() functions.
-// 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
-//
-// The Callback classes represent a generic function pointer. Internally,
-// it stores a refcounted piece of state that represents the target function
-// and all its bound parameters. Each Callback specialization has a templated
-// constructor that takes an BindState<>*. In the context of the constructor,
-// the static type of this BindState<> pointer uniquely identifies the
-// function it is representing, all its bound parameters, and a Run() method
-// that is capable of invoking the target.
-//
-// Callback's constructor takes the BindState<>* that has the full static type
-// and erases the target function type as well as the types of the bound
-// parameters. It does this by storing a pointer to the specific Run()
-// function, and upcasting the state of BindState<>* to a
-// BindStateBase*. This is safe as long as this BindStateBase pointer
-// is only used with the stored Run() pointer.
-//
-// To BindState<> objects are created inside the Bind() functions.
-// These functions, along with a set of internal templates, are responsible for
-//
-// - Unwrapping the function signature into return type, and parameters
-// - Determining the number of parameters that are bound
-// - Creating the BindState storing the bound parameters
-// - Performing compile-time asserts to avoid error-prone behavior
-// - Returning an Callback<> with an arity matching the number of unbound
-// parameters and that knows the correct refcounting semantics for the
-// target object if we are binding a method.
-//
-// The Bind functions do the above using type-inference, and template
-// specializations.
-//
-// By default Bind() will store copies of all bound parameters, and attempt
-// to refcount a target object if the function being bound is a class method.
-// These copies are created even if the function takes parameters as const
-// references. (Binding to non-const references is forbidden, see bind.h.)
-//
-// To change this behavior, we introduce a set of argument wrappers
-// (e.g., Unretained(), and ConstRef()). These are simple container templates
-// that are passed by value, and wrap a pointer to argument. See the
-// file-level comment in gutil/bind_helpers.h for more info.
-//
-// These types are passed to the Unwrap() functions, and the MaybeRefcount()
-// functions respectively to modify the behavior of Bind(). The Unwrap()
-// and MaybeRefcount() functions change behavior by doing partial
-// specialization based on whether or not a parameter is a wrapper type.
-//
-// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
-//
-//
-// WHY NOT TR1 FUNCTION/BIND?
-//
-// Direct use of tr1::function and tr1::bind was considered, but ultimately
-// rejected because of the number of copy constructors invocations involved
-// in the binding of arguments during construction, and the forwarding of
-// arguments during invocation. These copies will no longer be an issue in
-// C++0x because C++0x will support rvalue reference allowing for the compiler
-// to avoid these copies. However, waiting for C++0x is not an option.
-//
-// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
-// tr1::bind call itself will invoke a non-trivial copy constructor three times
-// for each bound parameter. Also, each when passing a tr1::function, each
-// bound argument will be copied again.
-//
-// In addition to the copies taken at binding and invocation, copying a
-// tr1::function causes a copy to be made of all the bound parameters and
-// state.
-//
-// Furthermore, in Chromium, it is desirable for the Callback to take a
-// reference on a target object when representing a class method call. This
-// is not supported by tr1.
-//
-// Lastly, tr1::function and tr1::bind has a more general and flexible API.
-// This includes things like argument reordering by use of
-// tr1::bind::placeholder, support for non-const reference parameters, and some
-// limited amount of subtyping of the tr1::function object (e.g.,
-// tr1::function<int(int)> is convertible to tr1::function<void(int)>).
-//
-// These are not features that are required in Chromium. Some of them, such as
-// allowing for reference parameters, and subtyping of functions, may actually
-// become a source of errors. Removing support for these features actually
-// allows for a simpler implementation, and a terser Currying API.
-//
-//
-// WHY NOT GOOGLE CALLBACKS?
-//
-// The Google callback system also does not support refcounting. Furthermore,
-// its implementation has a number of strange edge cases with respect to type
-// conversion of its arguments. In particular, the argument's constness must
-// at times match exactly the function signature, or the type-inference might
-// break. Given the above, writing a custom solution was easier.
-//
-//
-// MISSING FUNCTIONALITY
-// - Invoking the return of Bind. Bind(&foo).Run() does not work;
-// - Binding arrays to functions that take a non-const pointer.
-// Example:
-// void Foo(const char* ptr);
-// void Bar(char* ptr);
-// Bind(&Foo, "test");
-// Bind(&Bar, "test"); // This fails because ptr is not const.
-
-namespace kudu {
-
-// First, we forward declare the Callback class template. This informs the
-// compiler that the template only has 1 type parameter which is the function
-// signature that the Callback is representing.
-//
-// After this, create template specializations for 0-$(MAX_ARITY) parameters. Note that
-// even though the template typelist grows, the specialization still
-// only has one type: the function signature.
-//
-// If you are thinking of forward declaring Callback in your own header file,
-// please include "base/callback_forward.h" instead.
-template <typename Sig>
-class Callback;
-
-namespace internal {
-template <typename Runnable, typename RunType, typename BoundArgsType>
-struct BindState;
-} // namespace internal
-
-
-$range ARITY 0..MAX_ARITY
-$for ARITY [[
-$range ARG 1..ARITY
-
-$if ARITY == 0 [[
-template <typename R>
-class Callback<R(void)> : public internal::CallbackBase {
-]] $else [[
-template <typename R, $for ARG , [[typename A$(ARG)]]>
-class Callback<R($for ARG , [[A$(ARG)]])> : public internal::CallbackBase {
-]]
-
- public:
- typedef R(RunType)($for ARG , [[A$(ARG)]]);
-
- Callback() : CallbackBase(NULL) { }
-
- // Note that this constructor CANNOT be explicit, and that Bind() CANNOT
- // return the exact Callback<> type. See base/bind.h for details.
- template <typename Runnable, typename BindRunType, typename BoundArgsType>
- Callback(internal::BindState<Runnable, BindRunType,
- BoundArgsType>* bind_state)
- : CallbackBase(bind_state) {
-
- // Force the assignment to a local variable of PolymorphicInvoke
- // so the compiler will typecheck that the passed in Run() method has
- // the correct type.
- PolymorphicInvoke invoke_func =
- &internal::BindState<Runnable, BindRunType, BoundArgsType>
- ::InvokerType::Run;
- polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
- }
-
- bool Equals(const Callback& other) const {
- return CallbackBase::Equals(other);
- }
-
- R Run($for ARG ,
- [[typename internal::CallbackParamTraits<A$(ARG)>::ForwardType a$(ARG)]]) const {
- PolymorphicInvoke f =
- reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
-
- return f(bind_state_.get()[[]]
-$if ARITY != 0 [[, ]]
-$for ARG ,
- [[internal::CallbackForward(a$(ARG))]]);
- }
-
- private:
- typedef R(*PolymorphicInvoke)(
- internal::BindStateBase*[[]]
-$if ARITY != 0 [[, ]]
-$for ARG , [[typename internal::CallbackParamTraits<A$(ARG)>::ForwardType]]);
-
-};
-
-
-]] $$ for ARITY
-
-// Syntactic sugar to make Callbacks<void(void)> easier to declare since it
-// will be used in a lot of APIs with delayed execution.
-typedef Callback<void(void)> Closure;
-
-} // namespace kudu
-
-#endif // GUTIL_CALLBACK_H
diff --git a/be/src/gutil/callback_forward.h b/be/src/gutil/callback_forward.h
deleted file mode 100644
index 1f4958d3a..000000000
--- a/be/src/gutil/callback_forward.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef GUTIL_CALLBACK_FORWARD_H_
-#define GUTIL_CALLBACK_FORWARD_H_
-
-namespace kudu {
-
-template <typename Sig>
-class Callback;
-
-typedef Callback<void(void)> Closure;
-
-} // namespace kudu
-
-#endif // GUTIL_CALLBACK_FORWARD_H
diff --git a/be/src/gutil/callback_internal.cc b/be/src/gutil/callback_internal.cc
deleted file mode 100644
index 5a2483663..000000000
--- a/be/src/gutil/callback_internal.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gutil/callback_internal.h"
-
-namespace kudu {
-namespace internal {
-
-bool CallbackBase::is_null() const {
- return bind_state_.get() == nullptr;
-}
-
-void CallbackBase::Reset() {
- polymorphic_invoke_ = nullptr;
- // NULL the bind_state_ last, since it may be holding the last ref to whatever
- // object owns us, and we may be deleted after that.
- bind_state_ = nullptr;
-}
-
-bool CallbackBase::Equals(const CallbackBase& other) const {
- return bind_state_.get() == other.bind_state_.get() &&
- polymorphic_invoke_ == other.polymorphic_invoke_;
-}
-
-CallbackBase::CallbackBase(BindStateBase* bind_state)
- : bind_state_(bind_state),
- polymorphic_invoke_(nullptr) {
- DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
-}
-
-CallbackBase::~CallbackBase() {
-}
-
-} // namespace internal
-} // namespace kudu
diff --git a/be/src/gutil/callback_internal.h b/be/src/gutil/callback_internal.h
deleted file mode 100644
index ed91f4568..000000000
--- a/be/src/gutil/callback_internal.h
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file contains utility functions and classes that help the
-// implementation, and management of the Callback objects.
-
-#ifndef GUTIL_CALLBACK_INTERNAL_H_
-#define GUTIL_CALLBACK_INTERNAL_H_
-
-#include <stddef.h>
-
-#include "gutil/gscoped_ptr.h"
-#include "gutil/ref_counted.h"
-
-template <typename T>
-class ScopedVector;
-
-namespace kudu {
-namespace internal {
-
-// BindStateBase is used to provide an opaque handle that the Callback
-// class can use to represent a function object with bound arguments. It
-// behaves as an existential type that is used by a corresponding
-// DoInvoke function to perform the function execution. This allows
-// us to shield the Callback class from the types of the bound argument via
-// "type erasure."
-class BindStateBase : public RefCountedThreadSafe<BindStateBase> {
- protected:
- friend class RefCountedThreadSafe<BindStateBase>;
- virtual ~BindStateBase() {}
-};
-
-// Holds the Callback methods that don't require specialization to reduce
-// template bloat.
-class CallbackBase {
- public:
- // Returns true if Callback is null (doesn't refer to anything).
- bool is_null() const;
-
- // Returns the Callback into an uninitialized state.
- void Reset();
-
- protected:
- // In C++, it is safe to cast function pointers to function pointers of
- // another type. It is not okay to use void*. We create a InvokeFuncStorage
- // that that can store our function pointer, and then cast it back to
- // the original type on usage.
- typedef void(*InvokeFuncStorage)(void);
-
- // Returns true if this callback equals |other|. |other| may be null.
- bool Equals(const CallbackBase& other) const;
-
- // Allow initializing of |bind_state_| via the constructor to avoid default
- // initialization of the scoped_refptr. We do not also initialize
- // |polymorphic_invoke_| here because doing a normal assignment in the
- // derived Callback templates makes for much nicer compiler errors.
- explicit CallbackBase(BindStateBase* bind_state);
-
- // Force the destructor to be instantiated inside this translation unit so
- // that our subclasses will not get inlined versions. Avoids more template
- // bloat.
- ~CallbackBase();
-
- scoped_refptr<BindStateBase> bind_state_;
- InvokeFuncStorage polymorphic_invoke_;
-};
-
-// A helper template to determine if given type is non-const move-only-type,
-// i.e. if a value of the given type should be passed via .Pass() in a
-// destructive way.
-template <typename T> struct IsMoveOnlyType {
- template <typename U>
- static base::YesType Test(const typename U::MoveOnlyTypeForCPP03*);
-
- template <typename U>
- static base::NoType Test(...);
-
- static const bool value = sizeof(Test<T>(0)) == sizeof(base::YesType) &&
- !base::is_const<T>::value;
-};
-
-// This is a typetraits object that's used to take an argument type, and
-// extract a suitable type for storing and forwarding arguments.
-//
-// In particular, it strips off references, and converts arrays to
-// pointers for storage; and it avoids accidentally trying to create a
-// "reference of a reference" if the argument is a reference type.
-//
-// This array type becomes an issue for storage because we are passing bound
-// parameters by const reference. In this case, we end up passing an actual
-// array type in the initializer list which C++ does not allow. This will
-// break passing of C-string literals.
-template <typename T, bool is_move_only = IsMoveOnlyType<T>::value>
-struct CallbackParamTraits {
- typedef const T& ForwardType;
- typedef T StorageType;
-};
-
-// The Storage should almost be impossible to trigger unless someone manually
-// specifies type of the bind parameters. However, in case they do,
-// this will guard against us accidentally storing a reference parameter.
-//
-// The ForwardType should only be used for unbound arguments.
-template <typename T>
-struct CallbackParamTraits<T&, false> {
- typedef T& ForwardType;
- typedef T StorageType;
-};
-
-// Note that for array types, we implicitly add a const in the conversion. This
-// means that it is not possible to bind array arguments to functions that take
-// a non-const pointer. Trying to specialize the template based on a "const
-// T[n]" does not seem to match correctly, so we are stuck with this
-// restriction.
-template <typename T, size_t n>
-struct CallbackParamTraits<T[n], false> {
- typedef const T* ForwardType;
- typedef const T* StorageType;
-};
-
-// See comment for CallbackParamTraits<T[n]>.
-template <typename T>
-struct CallbackParamTraits<T[], false> {
- typedef const T* ForwardType;
- typedef const T* StorageType;
-};
-
-// Parameter traits for movable-but-not-copyable scopers.
-//
-// Callback<>/Bind() understands movable-but-not-copyable semantics where
-// the type cannot be copied but can still have its state destructively
-// transferred (aka. moved) to another instance of the same type by calling a
-// helper function. When used with Bind(), this signifies transferal of the
-// object's state to the target function.
-//
-// For these types, the ForwardType must not be a const reference, or a
-// reference. A const reference is inappropriate, and would break const
-// correctness, because we are implementing a destructive move. A non-const
-// reference cannot be used with temporaries which means the result of a
-// function or a cast would not be usable with Callback<> or Bind().
-template <typename T>
-struct CallbackParamTraits<T, true> {
- typedef T ForwardType;
- typedef T StorageType;
-};
-
-// CallbackForward() is a very limited simulation of C++11's std::forward()
-// used by the Callback/Bind system for a set of movable-but-not-copyable
-// types. It is needed because forwarding a movable-but-not-copyable
-// argument to another function requires us to invoke the proper move
-// operator to create a rvalue version of the type. The supported types are
-// whitelisted below as overloads of the CallbackForward() function. The
-// default template compiles out to be a no-op.
-//
-// In C++11, std::forward would replace all uses of this function. However, it
-// is impossible to implement a general std::forward with C++11 due to a lack
-// of rvalue references.
-//
-// In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to
-// simulate std::forward() and forward the result of one Callback as a
-// parameter to another callback. This is to support Callbacks that return
-// the movable-but-not-copyable types whitelisted above.
-template <typename T>
-typename base::enable_if<!IsMoveOnlyType<T>::value, T>::type& CallbackForward(T& t) {
- return t;
-}
-
-template <typename T>
-typename base::enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) {
- return t.Pass();
-}
-
-} // namespace internal
-} // namespace kudu
-
-#endif // GUTIL_CALLBACK_INTERNAL_H_
diff --git a/be/src/gutil/gscoped_ptr.h b/be/src/gutil/gscoped_ptr.h
deleted file mode 100644
index be1bb485b..000000000
--- a/be/src/gutil/gscoped_ptr.h
+++ /dev/null
@@ -1,830 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.txt file.
-
-// Scopers help you manage ownership of a pointer, helping you easily manage the
-// a pointer within a scope, and automatically destroying the pointer at the
-// end of a scope. There are two main classes you will use, which correspond
-// to the operators new/delete and new[]/delete[].
-//
-// Example usage (gscoped_ptr):
-// {
-// gscoped_ptr<Foo> foo(new Foo("wee"));
-// } // foo goes out of scope, releasing the pointer with it.
-//
-// {
-// gscoped_ptr<Foo> foo; // No pointer managed.
-// foo.reset(new Foo("wee")); // Now a pointer is managed.
-// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed.
-// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed.
-// foo->Method(); // Foo::Method() called.
-// foo.get()->Method(); // Foo::Method() called.
-// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer
-// // manages a pointer.
-// foo.reset(new Foo("wee4")); // foo manages a pointer again.
-// foo.reset(); // Foo("wee4") destroyed, foo no longer
-// // manages a pointer.
-// } // foo wasn't managing a pointer, so nothing was destroyed.
-//
-// Example usage (gscoped_array):
-// {
-// gscoped_array<Foo> foo(new Foo[100]);
-// foo.get()->Method(); // Foo::Method on the 0th element.
-// foo[10].Method(); // Foo::Method on the 10th element.
-// }
-//
-// These scopers also implement part of the functionality of C++11 unique_ptr
-// in that they are "movable but not copyable." You can use the scopers in
-// the parameter and return types of functions to signify ownership transfer
-// in to and out of a function. When calling a function that has a scoper
-// as the argument type, it must be called with the result of an analogous
-// scoper's Pass() function or another function that generates a temporary;
-// passing by copy will NOT work. Here is an example using gscoped_ptr:
-//
-// void TakesOwnership(gscoped_ptr<Foo> arg) {
-// // Do something with arg
-// }
-// gscoped_ptr<Foo> CreateFoo() {
-// // No need for calling Pass() because we are constructing a temporary
-// // for the return value.
-// return gscoped_ptr<Foo>(new Foo("new"));
-// }
-// gscoped_ptr<Foo> PassThru(gscoped_ptr<Foo> arg) {
-// return std::move(arg);
-// }
-//
-// {
-// gscoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
-// TakesOwnership(std::move(ptr)); // ptr no longer owns Foo("yay").
-// gscoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
-// gscoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
-// PassThru(std::move(ptr2)); // ptr2 is correspondingly NULL.
-// }
-//
-// Notice that if you do not call Pass() when returning from PassThru(), or
-// when invoking TakesOwnership(), the code will not compile because scopers
-// are not copyable; they only implement move semantics which require calling
-// the Pass() function to signify a destructive transfer of state. CreateFoo()
-// is different though because we are constructing a temporary on the return
-// line and thus can avoid needing to call Pass().
-//
-// Pass() properly handles upcast in assignment, i.e. you can assign
-// gscoped_ptr<Child> to gscoped_ptr<Parent>:
-//
-// gscoped_ptr<Foo> foo(new Foo());
-// gscoped_ptr<FooParent> parent = std::move(foo);
-//
-// PassAs<>() should be used to upcast return value in return statement:
-//
-// gscoped_ptr<Foo> CreateFoo() {
-// gscoped_ptr<FooChild> result(new FooChild());
-// return result.PassAs<Foo>();
-// }
-//
-// Note that PassAs<>() is implemented only for gscoped_ptr, but not for
-// gscoped_array. This is because casting array pointers may not be safe.
-//
-// -------------------------------------------------------------------------
-// Cloudera notes: this should be used in preference to boost::scoped_ptr since
-// it offers a ::release() method like unique_ptr. We unfortunately cannot
-// just use unique_ptr because it has an inconsistent implementation in
-// some of the older compilers we have to support.
-// -------------------------------------------------------------------------
-
-#ifndef GUTIL_GSCOPED_PTR_H_
-#define GUTIL_GSCOPED_PTR_H_
-
-// This is an implementation designed to match the anticipated future TR2
-// implementation of the scoped_ptr class, and its closely-related brethren,
-// scoped_array, scoped_ptr_malloc.
-
-#include <assert.h>
-#include <stddef.h>
-#include <stdlib.h>
-
-#include <algorithm> // For std::swap().
-
-#include "gutil/basictypes.h"
-#include "gutil/template_util.h"
-#include "gutil/type_traits.h"
-#include "gutil/move.h"
-
-namespace kudu {
-
-namespace subtle {
-class RefCountedBase;
-class RefCountedThreadSafeBase;
-} // namespace subtle
-
-// Function object which deletes its parameter, which must be a pointer.
-// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
-// invokes 'delete'. The default deleter for gscoped_ptr<T>.
-template <class T>
-struct DefaultDeleter {
- DefaultDeleter() {}
- template <typename U> DefaultDeleter(const DefaultDeleter<U>& other) {
- // IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor
- // if U* is implicitly convertible to T* and U is not an array type.
- //
- // Correct implementation should use SFINAE to disable this
- // constructor. However, since there are no other 1-argument constructors,
- // using a COMPILE_ASSERT() based on is_convertible<> and requiring
- // complete types is simpler and will cause compile failures for equivalent
- // misuses.
- //
- // Note, the is_convertible<U*, T*> check also ensures that U is not an
- // array. T is guaranteed to be a non-array, so any U* where U is an array
- // cannot convert to T*.
- enum { T_must_be_complete = sizeof(T) };
- enum { U_must_be_complete = sizeof(U) };
- COMPILE_ASSERT((base::is_convertible<U*, T*>::value),
- U_ptr_must_implicitly_convert_to_T_ptr);
- }
- inline void operator()(T* ptr) const {
- enum { type_must_be_complete = sizeof(T) };
- delete ptr;
- }
-};
-
-// Specialization of DefaultDeleter for array types.
-template <class T>
-struct DefaultDeleter<T[]> {
- inline void operator()(T* ptr) const {
- enum { type_must_be_complete = sizeof(T) };
- delete[] ptr;
- }
-
- private:
- // Disable this operator for any U != T because it is undefined to execute
- // an array delete when the static type of the array mismatches the dynamic
- // type.
- //
- // References:
- // C++98 [expr.delete]p3
- // http://cplusplus.github.com/LWG/lwg-defects.html#938
- template <typename U> void operator()(U* array) const;
-};
-
-template <class T, int n>
-struct DefaultDeleter<T[n]> {
- // Never allow someone to declare something like gscoped_ptr<int[10]>.
- COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
-};
-
-// Function object which invokes 'free' on its parameter, which must be
-// a pointer. Can be used to store malloc-allocated pointers in gscoped_ptr:
-//
-// gscoped_ptr<int, kudu::FreeDeleter> foo_ptr(
-// static_cast<int*>(malloc(sizeof(int))));
-struct FreeDeleter {
- inline void operator()(void* ptr) const {
- free(ptr);
- }
-};
-
-namespace internal {
-
-template <typename T> struct IsNotRefCounted {
- enum {
- value = !base::is_convertible<T*, kudu::subtle::RefCountedBase*>::value &&
- !base::is_convertible<T*, kudu::subtle::RefCountedThreadSafeBase*>::
- value
- };
-};
-
-// Minimal implementation of the core logic of gscoped_ptr, suitable for
-// reuse in both gscoped_ptr and its specializations.
-template <class T, class D>
-class gscoped_ptr_impl {
- public:
- explicit gscoped_ptr_impl(T* p) : data_(p) { }
-
- // Initializer for deleters that have data parameters.
- gscoped_ptr_impl(T* p, const D& d) : data_(p, d) {}
-
- // Templated constructor that destructively takes the value from another
- // gscoped_ptr_impl.
- template <typename U, typename V>
- gscoped_ptr_impl(gscoped_ptr_impl<U, V>* other)
- : data_(other->release(), other->get_deleter()) {
- // We do not support move-only deleters. We could modify our move
- // emulation to have base::subtle::move() and base::subtle::forward()
- // functions that are imperfect emulations of their C++11 equivalents,
- // but until there's a requirement, just assume deleters are copyable.
- }
-
- template <typename U, typename V>
- void TakeState(gscoped_ptr_impl<U, V>* other) {
- // See comment in templated constructor above regarding lack of support
- // for move-only deleters.
- reset(other->release());
- get_deleter() = other->get_deleter();
- }
-
- ~gscoped_ptr_impl() {
- if (data_.ptr != NULL) {
- // Not using get_deleter() saves one function call in non-optimized
- // builds.
- static_cast<D&>(data_)(data_.ptr);
- }
- }
-
- void reset(T* p) {
- // This is a self-reset, which is no longer allowed: http://crbug.com/162971
- if (p != NULL && p == data_.ptr)
- abort();
-
- // Note that running data_.ptr = p can lead to undefined behavior if
- // get_deleter()(get()) deletes this. In order to pevent this, reset()
- // should update the stored pointer before deleting its old value.
- //
- // However, changing reset() to use that behavior may cause current code to
- // break in unexpected ways. If the destruction of the owned object
- // dereferences the gscoped_ptr when it is destroyed by a call to reset(),
- // then it will incorrectly dispatch calls to |p| rather than the original
- // value of |data_.ptr|.
- //
- // During the transition period, set the stored pointer to NULL while
- // deleting the object. Eventually, this safety check will be removed to
- // prevent the scenario initially described from occuring and
- // http://crbug.com/176091 can be closed.
- T* old = data_.ptr;
- data_.ptr = NULL;
- if (old != NULL)
- static_cast<D&>(data_)(old);
- data_.ptr = p;
- }
-
- T* get() const { return data_.ptr; }
-
- D& get_deleter() { return data_; }
- const D& get_deleter() const { return data_; }
-
- void swap(gscoped_ptr_impl& p2) {
- // Standard swap idiom: 'using std::swap' ensures that std::swap is
- // present in the overload set, but we call swap unqualified so that
- // any more-specific overloads can be used, if available.
- using std::swap;
- swap(static_cast<D&>(data_), static_cast<D&>(p2.data_));
- swap(data_.ptr, p2.data_.ptr);
- }
-
- T* release() {
- T* old_ptr = data_.ptr;
- data_.ptr = NULL;
- return old_ptr;
- }
-
- private:
- // Needed to allow type-converting constructor.
- template <typename U, typename V> friend class gscoped_ptr_impl;
-
- // Use the empty base class optimization to allow us to have a D
- // member, while avoiding any space overhead for it when D is an
- // empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good
- // discussion of this technique.
- struct Data : public D {
- explicit Data(T* ptr_in) : ptr(ptr_in) {}
- Data(T* ptr_in, D other) : D(std::move(other)), ptr(ptr_in) {}
- T* ptr;
- };
-
- Data data_;
-
- DISALLOW_COPY_AND_ASSIGN(gscoped_ptr_impl);
-};
-
-} // namespace internal
-
-} // namespace kudu
-
-// A gscoped_ptr<T> is like a T*, except that the destructor of gscoped_ptr<T>
-// automatically deletes the pointer it holds (if any).
-// That is, gscoped_ptr<T> owns the T object that it points to.
-// Like a T*, a gscoped_ptr<T> may hold either NULL or a pointer to a T object.
-// Also like T*, gscoped_ptr<T> is thread-compatible, and once you
-// dereference it, you get the thread safety guarantees of T.
-//
-// The size of gscoped_ptr is small. On most compilers, when using the
-// DefaultDeleter, sizeof(gscoped_ptr<T>) == sizeof(T*). Custom deleters will
-// increase the size proportional to whatever state they need to have. See
-// comments inside gscoped_ptr_impl<> for details.
-//
-// Current implementation targets having a strict subset of C++11's
-// unique_ptr<> features. Known deficiencies include not supporting move-only
-// deleteres, function pointers as deleters, and deleters with reference
-// types.
-template <class T, class D = kudu::DefaultDeleter<T> >
-class gscoped_ptr {
- MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_ptr, RValue)
-
- COMPILE_ASSERT(kudu::internal::IsNotRefCounted<T>::value,
- T_is_refcounted_type_and_needs_scoped_refptr);
-
- public:
- // The element and deleter types.
- typedef T element_type;
- typedef D deleter_type;
-
- // Constructor. Defaults to initializing with NULL.
- gscoped_ptr() : impl_(NULL) { }
-
- // Constructor. Takes ownership of p.
- explicit gscoped_ptr(element_type* p) : impl_(p) { }
-
- // Constructor. Allows initialization of a stateful deleter.
- gscoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
-
- // Constructor. Allows construction from a gscoped_ptr rvalue for a
- // convertible type and deleter.
- //
- // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct
- // from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor
- // has different post-conditions if D is a reference type. Since this
- // implementation does not support deleters with reference type,
- // we do not need a separate move constructor allowing us to avoid one
- // use of SFINAE. You only need to care about this if you modify the
- // implementation of gscoped_ptr.
- template <typename U, typename V>
- gscoped_ptr(gscoped_ptr<U, V> other) : impl_(&other.impl_) {
- COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
- }
-
- // Constructor. Move constructor for C++03 move emulation of this type.
- gscoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
-
- // operator=. Allows assignment from a gscoped_ptr rvalue for a convertible
- // type and deleter.
- //
- // IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from
- // the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated
- // form has different requirements on for move-only Deleters. Since this
- // implementation does not support move-only Deleters, we do not need a
- // separate move assignment operator allowing us to avoid one use of SFINAE.
- // You only need to care about this if you modify the implementation of
- // gscoped_ptr.
- template <typename U, typename V>
- gscoped_ptr& operator=(gscoped_ptr<U, V> rhs) {
- COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
- impl_.TakeState(&rhs.impl_);
- return *this;
- }
-
- // Reset. Deletes the currently owned object, if any.
- // Then takes ownership of a new object, if given.
- void reset(element_type* p = NULL) { impl_.reset(p); }
-
- // Accessors to get the owned object.
- // operator* and operator-> will assert() if there is no current object.
- element_type& operator*() const {
- assert(impl_.get() != NULL);
- return *impl_.get();
- }
- element_type* operator->() const {
- assert(impl_.get() != NULL);
- return impl_.get();
- }
- element_type* get() const { return impl_.get(); }
-
- // Access to the deleter.
- deleter_type& get_deleter() { return impl_.get_deleter(); }
- const deleter_type& get_deleter() const { return impl_.get_deleter(); }
-
- // Allow gscoped_ptr<element_type> to be used in boolean expressions, but not
- // implicitly convertible to a real bool (which is dangerous).
- private:
- typedef kudu::internal::gscoped_ptr_impl<element_type, deleter_type>
- gscoped_ptr::*Testable;
-
- public:
- operator Testable() const { return impl_.get() ? &gscoped_ptr::impl_ : NULL; }
-
- // Comparison operators.
- // These return whether two gscoped_ptr refer to the same object, not just to
- // two different but equal objects.
- bool operator==(const element_type* p) const { return impl_.get() == p; }
- bool operator!=(const element_type* p) const { return impl_.get() != p; }
-
- // Swap two scoped pointers.
- void swap(gscoped_ptr& p2) {
- impl_.swap(p2.impl_);
- }
-
- // Release a pointer.
- // The return value is the current pointer held by this object.
- // If this object holds a NULL pointer, the return value is NULL.
- // After this operation, this object will hold a NULL pointer,
- // and will not own the object any more.
- element_type* release() WARN_UNUSED_RESULT {
- return impl_.release();
- }
-
- // C++98 doesn't support functions templates with default parameters which
- // makes it hard to write a PassAs() that understands converting the deleter
- // while preserving simple calling semantics.
- //
- // Until there is a use case for PassAs() with custom deleters, just ignore
- // the custom deleter.
- template <typename PassAsType>
- gscoped_ptr<PassAsType> PassAs() {
- return gscoped_ptr<PassAsType>(Pass());
- }
-
- private:
- // Needed to reach into |impl_| in the constructor.
- template <typename U, typename V> friend class gscoped_ptr;
- kudu::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
-
- // Forbid comparison of gscoped_ptr types. If U != T, it totally
- // doesn't make sense, and if U == T, it still doesn't make sense
- // because you should never have the same object owned by two different
- // gscoped_ptrs.
- template <class U> bool operator==(gscoped_ptr<U> const& p2) const;
- template <class U> bool operator!=(gscoped_ptr<U> const& p2) const;
-};
-
-template <class T, class D>
-class gscoped_ptr<T[], D> {
- MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_ptr, RValue)
-
- public:
- // The element and deleter types.
- typedef T element_type;
- typedef D deleter_type;
-
- // Constructor. Defaults to initializing with NULL.
- gscoped_ptr() : impl_(NULL) { }
-
- // Constructor. Stores the given array. Note that the argument's type
- // must exactly match T*. In particular:
- // - it cannot be a pointer to a type derived from T, because it is
- // inherently unsafe in the general case to access an array through a
- // pointer whose dynamic type does not match its static type (eg., if
- // T and the derived types had different sizes access would be
- // incorrectly calculated). Deletion is also always undefined
- // (C++98 [expr.delete]p3). If you're doing this, fix your code.
- // - it cannot be NULL, because NULL is an integral expression, not a
- // pointer to T. Use the no-argument version instead of explicitly
- // passing NULL.
- // - it cannot be const-qualified differently from T per unique_ptr spec
- // (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting
- // to work around this may use implicit_cast<const T*>().
- // However, because of the first bullet in this comment, users MUST
- // NOT use implicit_cast<Base*>() to upcast the static type of the array.
- explicit gscoped_ptr(element_type* array) : impl_(array) { }
-
- // Constructor. Move constructor for C++03 move emulation of this type.
- gscoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
-
- // operator=. Move operator= for C++03 move emulation of this type.
- gscoped_ptr& operator=(RValue rhs) {
- impl_.TakeState(&rhs.object->impl_);
- return *this;
- }
-
- // Reset. Deletes the currently owned array, if any.
- // Then takes ownership of a new object, if given.
- void reset(element_type* array = NULL) { impl_.reset(array); }
-
- // Accessors to get the owned array.
- element_type& operator[](size_t i) const {
- assert(impl_.get() != NULL);
- return impl_.get()[i];
- }
- element_type* get() const { return impl_.get(); }
-
- // Access to the deleter.
- deleter_type& get_deleter() { return impl_.get_deleter(); }
- const deleter_type& get_deleter() const { return impl_.get_deleter(); }
-
- // Allow gscoped_ptr<element_type> to be used in boolean expressions, but not
- // implicitly convertible to a real bool (which is dangerous).
- private:
- typedef kudu::internal::gscoped_ptr_impl<element_type, deleter_type>
- gscoped_ptr::*Testable;
-
- public:
- operator Testable() const { return impl_.get() ? &gscoped_ptr::impl_ : NULL; }
-
- // Comparison operators.
- // These return whether two gscoped_ptr refer to the same object, not just to
- // two different but equal objects.
- bool operator==(element_type* array) const { return impl_.get() == array; }
- bool operator!=(element_type* array) const { return impl_.get() != array; }
-
- // Swap two scoped pointers.
- void swap(gscoped_ptr& p2) {
- impl_.swap(p2.impl_);
- }
-
- // Release a pointer.
- // The return value is the current pointer held by this object.
- // If this object holds a NULL pointer, the return value is NULL.
- // After this operation, this object will hold a NULL pointer,
- // and will not own the object any more.
- element_type* release() WARN_UNUSED_RESULT {
- return impl_.release();
- }
-
- private:
- // Force element_type to be a complete type.
- enum { type_must_be_complete = sizeof(element_type) };
-
- // Actually hold the data.
- kudu::internal::gscoped_ptr_impl<element_type, deleter_type> impl_;
-
- // Disable initialization from any type other than element_type*, by
- // providing a constructor that matches such an initialization, but is
- // private and has no definition. This is disabled because it is not safe to
- // call delete[] on an array whose static type does not match its dynamic
- // type.
- template <typename U> explicit gscoped_ptr(U* array);
- explicit gscoped_ptr(int disallow_construction_from_null);
-
- // Disable reset() from any type other than element_type*, for the same
- // reasons as the constructor above.
- template <typename U> void reset(U* array);
- void reset(int disallow_reset_from_null);
-
- // Forbid comparison of gscoped_ptr types. If U != T, it totally
- // doesn't make sense, and if U == T, it still doesn't make sense
- // because you should never have the same object owned by two different
- // gscoped_ptrs.
- template <class U> bool operator==(gscoped_ptr<U> const& p2) const;
- template <class U> bool operator!=(gscoped_ptr<U> const& p2) const;
-};
-
-// Free functions
-template <class T, class D>
-void swap(gscoped_ptr<T, D>& p1, gscoped_ptr<T, D>& p2) {
- p1.swap(p2);
-}
-
-template <class T, class D>
-bool operator==(T* p1, const gscoped_ptr<T, D>& p2) {
- return p1 == p2.get();
-}
-
-template <class T, class D>
-bool operator!=(T* p1, const gscoped_ptr<T, D>& p2) {
- return p1 != p2.get();
-}
-
-// DEPRECATED: Use gscoped_ptr<C[]> instead.
-//
-// gscoped_array<C> is like gscoped_ptr<C>, except that the caller must allocate
-// with new [] and the destructor deletes objects with delete [].
-//
-// As with gscoped_ptr<C>, a gscoped_array<C> either points to an object
-// or is NULL. A gscoped_array<C> owns the object that it points to.
-// gscoped_array<T> is thread-compatible, and once you index into it,
-// the returned objects have only the thread safety guarantees of T.
-//
-// Size: sizeof(gscoped_array<C>) == sizeof(C*)
-template <class C>
-class gscoped_array {
- MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_array, RValue)
-
- public:
-
- // The element type
- typedef C element_type;
-
- // Constructor. Defaults to initializing with NULL.
- // There is no way to create an uninitialized gscoped_array.
- // The input parameter must be allocated with new [].
- explicit gscoped_array(C* p = NULL) : array_(p) { }
-
- // Constructor. Move constructor for C++03 move emulation of this type.
- gscoped_array(RValue rvalue)
- : array_(rvalue.object->release()) {
- }
-
- // Destructor. If there is a C object, delete it.
- // We don't need to test ptr_ == NULL because C++ does that for us.
- ~gscoped_array() {
- enum { type_must_be_complete = sizeof(C) };
- delete[] array_;
- }
-
- // operator=. Move operator= for C++03 move emulation of this type.
- gscoped_array& operator=(RValue rhs) {
- reset(rhs.object->release());
- return *this;
- }
-
- // Reset. Deletes the current owned object, if any.
- // Then takes ownership of a new object, if given.
- // this->reset(this->get()) works.
- void reset(C* p = NULL) {
- if (p != array_) {
- enum { type_must_be_complete = sizeof(C) };
- delete[] array_;
- array_ = p;
- }
- }
-
- // Get one element of the current object.
- // Will assert() if there is no current object, or index i is negative.
- C& operator[](ptrdiff_t i) const {
- assert(i >= 0);
- assert(array_ != NULL);
- return array_[i];
- }
-
- // Get a pointer to the zeroth element of the current object.
- // If there is no current object, return NULL.
- C* get() const {
- return array_;
- }
-
- // Allow gscoped_array<C> to be used in boolean expressions, but not
- // implicitly convertible to a real bool (which is dangerous).
- typedef C* gscoped_array::*Testable;
- operator Testable() const { return array_ ? &gscoped_array::array_ : NULL; }
-
- // Comparison operators.
- // These return whether two gscoped_array refer to the same object, not just to
- // two different but equal objects.
- bool operator==(C* p) const { return array_ == p; }
- bool operator!=(C* p) const { return array_ != p; }
-
- // Swap two scoped arrays.
- void swap(gscoped_array& p2) {
- C* tmp = array_;
- array_ = p2.array_;
- p2.array_ = tmp;
- }
-
- // Release an array.
- // The return value is the current pointer held by this object.
- // If this object holds a NULL pointer, the return value is NULL.
- // After this operation, this object will hold a NULL pointer,
- // and will not own the object any more.
- C* release() WARN_UNUSED_RESULT {
- C* retVal = array_;
- array_ = NULL;
- return retVal;
- }
-
- private:
- C* array_;
-
- // Forbid comparison of different gscoped_array types.
- template <class C2> bool operator==(gscoped_array<C2> const& p2) const;
- template <class C2> bool operator!=(gscoped_array<C2> const& p2) const;
-};
-
-// Free functions
-template <class C>
-void swap(gscoped_array<C>& p1, gscoped_array<C>& p2) {
- p1.swap(p2);
-}
-
-template <class C>
-bool operator==(C* p1, const gscoped_array<C>& p2) {
- return p1 == p2.get();
-}
-
-template <class C>
-bool operator!=(C* p1, const gscoped_array<C>& p2) {
- return p1 != p2.get();
-}
-
-// DEPRECATED: Use gscoped_ptr<C, kudu::FreeDeleter> instead.
-//
-// gscoped_ptr_malloc<> is similar to gscoped_ptr<>, but it accepts a
-// second template argument, the functor used to free the object.
-
-template<class C, class FreeProc = kudu::FreeDeleter>
-class gscoped_ptr_malloc {
- MOVE_ONLY_TYPE_FOR_CPP_03(gscoped_ptr_malloc, RValue)
-
- public:
-
- // The element type
- typedef C element_type;
-
- // Constructor. Defaults to initializing with NULL.
- // There is no way to create an uninitialized gscoped_ptr.
- // The input parameter must be allocated with an allocator that matches the
- // Free functor. For the default Free functor, this is malloc, calloc, or
- // realloc.
- explicit gscoped_ptr_malloc(C* p = NULL): ptr_(p) {}
-
- // Constructor. Move constructor for C++03 move emulation of this type.
- gscoped_ptr_malloc(RValue rvalue)
- : ptr_(rvalue.object->release()) {
- }
-
- // Destructor. If there is a C object, call the Free functor.
- ~gscoped_ptr_malloc() {
- reset();
- }
-
- // operator=. Move operator= for C++03 move emulation of this type.
- gscoped_ptr_malloc& operator=(RValue rhs) {
- reset(rhs.object->release());
- return *this;
- }
-
- // Reset. Calls the Free functor on the current owned object, if any.
- // Then takes ownership of a new object, if given.
- // this->reset(this->get()) works.
- void reset(C* p = NULL) {
- if (ptr_ != p) {
- if (ptr_ != NULL) {
- FreeProc free_proc;
- free_proc(ptr_);
- }
- ptr_ = p;
- }
- }
-
- // Get the current object.
- // operator* and operator-> will cause an assert() failure if there is
- // no current object.
- C& operator*() const {
- assert(ptr_ != NULL);
- return *ptr_;
- }
-
- C* operator->() const {
- assert(ptr_ != NULL);
- return ptr_;
- }
-
- C* get() const {
- return ptr_;
- }
-
- // Allow gscoped_ptr_malloc<C> to be used in boolean expressions, but not
- // implicitly convertible to a real bool (which is dangerous).
- typedef C* gscoped_ptr_malloc::*Testable;
- operator Testable() const { return ptr_ ? &gscoped_ptr_malloc::ptr_ : NULL; }
-
- // Comparison operators.
- // These return whether a gscoped_ptr_malloc and a plain pointer refer
- // to the same object, not just to two different but equal objects.
- // For compatibility with the boost-derived implementation, these
- // take non-const arguments.
- bool operator==(C* p) const {
- return ptr_ == p;
- }
-
- bool operator!=(C* p) const {
- return ptr_ != p;
- }
-
- // Swap two scoped pointers.
- void swap(gscoped_ptr_malloc & b) {
- C* tmp = b.ptr_;
- b.ptr_ = ptr_;
- ptr_ = tmp;
- }
-
- // Release a pointer.
- // The return value is the current pointer held by this object.
- // If this object holds a NULL pointer, the return value is NULL.
- // After this operation, this object will hold a NULL pointer,
- // and will not own the object any more.
- C* release() WARN_UNUSED_RESULT {
- C* tmp = ptr_;
- ptr_ = NULL;
- return tmp;
- }
-
- private:
- C* ptr_;
-
- // no reason to use these: each gscoped_ptr_malloc should have its own object
- template <class C2, class GP>
- bool operator==(gscoped_ptr_malloc<C2, GP> const& p) const;
- template <class C2, class GP>
- bool operator!=(gscoped_ptr_malloc<C2, GP> const& p) const;
-};
-
-template<class C, class FP> inline
-void swap(gscoped_ptr_malloc<C, FP>& a, gscoped_ptr_malloc<C, FP>& b) {
- a.swap(b);
-}
-
-template<class C, class FP> inline
-bool operator==(C* p, const gscoped_ptr_malloc<C, FP>& b) {
- return p == b.get();
-}
-
-template<class C, class FP> inline
-bool operator!=(C* p, const gscoped_ptr_malloc<C, FP>& b) {
- return p != b.get();
-}
-
-// A function to convert T* into gscoped_ptr<T>
-// Doing e.g. make_gscoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
-// for gscoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
-template <typename T>
-gscoped_ptr<T> make_gscoped_ptr(T* ptr) {
- return gscoped_ptr<T>(ptr);
-}
-
-#endif // GUTIL_GSCOPED_PTR_H_
diff --git a/be/src/gutil/move.h b/be/src/gutil/move.h
deleted file mode 100644
index 17651086b..000000000
--- a/be/src/gutil/move.h
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_MOVE_H_
-#define BASE_MOVE_H_
-
-// Macro with the boilerplate that makes a type move-only in C++03.
-//
-// USAGE
-//
-// This macro should be used instead of DISALLOW_COPY_AND_ASSIGN to create
-// a "move-only" type. Unlike DISALLOW_COPY_AND_ASSIGN, this macro should be
-// the first line in a class declaration.
-//
-// A class using this macro must call .Pass() (or somehow be an r-value already)
-// before it can be:
-//
-// * Passed as a function argument
-// * Used as the right-hand side of an assignment
-// * Returned from a function
-//
-// Each class will still need to define their own "move constructor" and "move
-// operator=" to make this useful. Here's an example of the macro, the move
-// constructor, and the move operator= from the scoped_ptr class:
-//
-// template <typename T>
-// class scoped_ptr {
-// MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
-// public:
-// scoped_ptr(RValue& other) : ptr_(other.release()) { }
-// scoped_ptr& operator=(RValue& other) {
-// swap(other);
-// return *this;
-// }
-// };
-//
-// Note that the constructor must NOT be marked explicit.
-//
-// For consistency, the second parameter to the macro should always be RValue
-// unless you have a strong reason to do otherwise. It is only exposed as a
-// macro parameter so that the move constructor and move operator= don't look
-// like they're using a phantom type.
-//
-//
-// HOW THIS WORKS
-//
-// For a thorough explanation of this technique, see:
-//
-// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor
-//
-// The summary is that we take advantage of 2 properties:
-//
-// 1) non-const references will not bind to r-values.
-// 2) C++ can apply one user-defined conversion when initializing a
-// variable.
-//
-// The first lets us disable the copy constructor and assignment operator
-// by declaring private version of them with a non-const reference parameter.
-//
-// For l-values, direct initialization still fails like in
-// DISALLOW_COPY_AND_ASSIGN because the copy constructor and assignment
-// operators are private.
-//
-// For r-values, the situation is different. The copy constructor and
-// assignment operator are not viable due to (1), so we are trying to call
-// a non-existent constructor and non-existing operator= rather than a private
-// one. Since we have not committed an error quite yet, we can provide an
-// alternate conversion sequence and a constructor. We add
-//
-// * a private struct named "RValue"
-// * a user-defined conversion "operator RValue()"
-// * a "move constructor" and "move operator=" that take the RValue& as
-// their sole parameter.
-//
-// Only r-values will trigger this sequence and execute our "move constructor"
-// or "move operator=." L-values will match the private copy constructor and
-// operator= first giving a "private in this context" error. This combination
-// gives us a move-only type.
-//
-// For signaling a destructive transfer of data from an l-value, we provide a
-// method named Pass() which creates an r-value for the current instance
-// triggering the move constructor or move operator=.
-//
-// Other ways to get r-values is to use the result of an expression like a
-// function call.
-//
-// Here's an example with comments explaining what gets triggered where:
-//
-// class Foo {
-// MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue);
-//
-// public:
-// ... API ...
-// Foo(RValue other); // Move constructor.
-// Foo& operator=(RValue rhs); // Move operator=
-// };
-//
-// Foo MakeFoo(); // Function that returns a Foo.
-//
-// Foo f;
-// Foo f_copy(f); // ERROR: Foo(Foo&) is private in this context.
-// Foo f_assign;
-// f_assign = f; // ERROR: operator=(Foo&) is private in this context.
-//
-//
-// Foo f(MakeFoo()); // R-value so alternate conversion executed.
-// Foo f_copy(std::move(f)); // R-value so alternate conversion executed.
-// f = std::move(f_copy); // R-value so alternate conversion executed.
-//
-//
-// IMPLEMENTATION SUBTLETIES WITH RValue
-//
-// The RValue struct is just a container for a pointer back to the original
-// object. It should only ever be created as a temporary, and no external
-// class should ever declare it or use it in a parameter.
-//
-// It is tempting to want to use the RValue type in function parameters, but
-// excluding the limited usage here for the move constructor and move
-// operator=, doing so would mean that the function could take both r-values
-// and l-values equially which is unexpected. See COMPARED To Boost.Move for
-// more details.
-//
-// An alternate, and incorrect, implementation of the RValue class used by
-// Boost.Move makes RValue a fieldless child of the move-only type. RValue&
-// is then used in place of RValue in the various operators. The RValue& is
-// "created" by doing *reinterpret_cast<RValue*>(this). This has the appeal
-// of never creating a temporary RValue struct even with optimizations
-// disabled. Also, by virtue of inheritance you can treat the RValue
-// reference as if it were the move-only type itself. Unfortunately,
-// using the result of this reinterpret_cast<> is actually undefined behavior
-// due to C++98 5.2.10.7. In certain compilers (e.g., NaCl) the optimizer
-// will generate non-working code.
-//
-// In optimized builds, both implementations generate the same assembly so we
-// choose the one that adheres to the standard.
-//
-//
-// WHY HAVE typedef void MoveOnlyTypeForCPP03
-//
-// Callback<>/Bind() needs to understand movable-but-not-copyable semantics
-// to call .Pass() appropriately when it is expected to transfer the value.
-// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check
-// easy and automatic in helper templates for Callback<>/Bind().
-// See IsMoveOnlyType template and its usage in base/callback_internal.h
-// for more details.
-//
-//
-// COMPARED TO C++11
-//
-// In C++11, you would implement this functionality using an r-value reference
-// and our .Pass() method would be replaced with a call to std::move().
-//
-// This emulation also has a deficiency where it uses up the single
-// user-defined conversion allowed by C++ during initialization. This can
-// cause problems in some API edge cases. For instance, in scoped_ptr, it is
-// impossible to make a function "void Foo(scoped_ptr<Parent> p)" accept a
-// value of type scoped_ptr<Child> even if you add a constructor to
-// scoped_ptr<> that would make it look like it should work. C++11 does not
-// have this deficiency.
-//
-//
-// COMPARED TO Boost.Move
-//
-// Our implementation similar to Boost.Move, but we keep the RValue struct
-// private to the move-only type, and we don't use the reinterpret_cast<> hack.
-//
-// In Boost.Move, RValue is the boost::rv<> template. This type can be used
-// when writing APIs like:
-//
-// void MyFunc(boost::rv<Foo>& f)
-//
-// that can take advantage of rv<> to avoid extra copies of a type. However you
-// would still be able to call this version of MyFunc with an l-value:
-//
-// Foo f;
-// MyFunc(f); // Uh oh, we probably just destroyed |f| w/o calling Pass().
-//
-// unless someone is very careful to also declare a parallel override like:
-//
-// void MyFunc(const Foo& f)
-//
-// that would catch the l-values first. This was declared unsafe in C++11 and
-// a C++11 compiler will explicitly fail MyFunc(f). Unfortunately, we cannot
-// ensure this in C++03.
-//
-// Since we have no need for writing such APIs yet, our implementation keeps
-// RValue private and uses a .Pass() method to do the conversion instead of
-// trying to write a version of "std::move()." Writing an API like std::move()
-// would require the RValue struct to be public.
-//
-//
-// CAVEATS
-//
-// If you include a move-only type as a field inside a class that does not
-// explicitly declare a copy constructor, the containing class's implicit
-// copy constructor will change from Containing(const Containing&) to
-// Containing(Containing&). This can cause some unexpected errors.
-//
-// http://llvm.org/bugs/show_bug.cgi?id=11528
-//
-// The workaround is to explicitly declare your copy constructor.
-//
-#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
- private: \
- struct rvalue_type { \
- explicit rvalue_type(type* object) : object(object) {} \
- type* object; \
- }; \
- type(type&); \
- void operator=(type&); \
- public: \
- operator rvalue_type() { return rvalue_type(this); } \
- type Pass() { return type(rvalue_type(this)); } \
- typedef void MoveOnlyTypeForCPP03; \
- private:
-
-#endif // BASE_MOVE_H_
diff --git a/be/src/gutil/stl_util.h b/be/src/gutil/stl_util.h
index 7e72b25c6..b8d672bfd 100644
--- a/be/src/gutil/stl_util.h
+++ b/be/src/gutil/stl_util.h
@@ -947,30 +947,4 @@ bool SortedRangesHaveIntersection(InputIterator1 begin1, InputIterator1 end1,
return false;
}
-// release_ptr is intended to help remove systematic use of gscoped_ptr
-// in cases like:
-//
-// vector<Foo *> v;
-// ElementDeleter d(&v);
-// ... {
-// int remove_idx = f(v);
-// gscoped_ptr<Foo> t(v[remove_idx]);
-// v[remove_idx] = NULL; // Save from deleter.
-// return t.release();
-// }
-//
-// This would be replaced by:
-// ... {
-// int remove_idx = f(v);
-// return release_ptr(&v[remove_idx]);
-// }
-template<typename T> T* release_ptr(T **ptr) MUST_USE_RESULT;
-template<typename T> T* release_ptr(T **ptr) {
- assert(ptr);
- T *tmp = *ptr;
- *ptr = NULL;
- return tmp;
-}
-
-
#endif // UTIL_GTL_STL_UTIL_H_
diff --git a/be/src/gutil/strings/escaping.cc b/be/src/gutil/strings/escaping.cc
index aaae9bf98..799c29c50 100644
--- a/be/src/gutil/strings/escaping.cc
+++ b/be/src/gutil/strings/escaping.cc
@@ -8,18 +8,20 @@
#include <string.h>
#include <limits>
-using std::numeric_limits;
+#include <memory>
#include <vector>
-using std::vector;
#include "gutil/integral_types.h"
#include "gutil/port.h"
-#include "gutil/gscoped_ptr.h"
#include "gutil/strings/join.h"
#include "gutil/utf/utf.h" // for runetochar
#include "gutil/charmap.h"
#include "gutil/stl_util.h"
+using std::numeric_limits;
+using std::unique_ptr;
+using std::vector;
+
namespace strings {
// These are used for the leave_nulls_escaped argument to CUnescapeInternal().
@@ -229,7 +231,7 @@ int UnescapeCEscapeString(const string& src, string* dest,
}
string UnescapeCEscapeString(const string& src) {
- gscoped_array<char> unescaped(new char[src.size() + 1]);
+ unique_ptr<char[]> unescaped(new char[src.size() + 1]);
int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), nullptr);
return string(unescaped.get(), len);
}
@@ -581,7 +583,7 @@ int Utf8SafeCHexEscapeString(const char* src, int src_len, char* dest,
// ----------------------------------------------------------------------
string CEscape(const StringPiece& src) {
const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
- gscoped_array<char> dest(new char[dest_length]);
+ unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, false, false);
DCHECK_GE(len, 0);
@@ -590,7 +592,7 @@ string CEscape(const StringPiece& src) {
string CHexEscape(const StringPiece& src) {
const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
- gscoped_array<char> dest(new char[dest_length]);
+ unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, true, false);
DCHECK_GE(len, 0);
@@ -599,7 +601,7 @@ string CHexEscape(const StringPiece& src) {
string Utf8SafeCEscape(const StringPiece& src) {
const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
- gscoped_array<char> dest(new char[dest_length]);
+ unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, false, true);
DCHECK_GE(len, 0);
@@ -608,7 +610,7 @@ string Utf8SafeCEscape(const StringPiece& src) {
string Utf8SafeCHexEscape(const StringPiece& src) {
const int dest_length = src.size() * 4 + 1; // Maximum possible expansion
- gscoped_array<char> dest(new char[dest_length]);
+ unique_ptr<char[]> dest(new char[dest_length]);
const int len = CEscapeInternal(src.data(), src.size(),
dest.get(), dest_length, true, true);
DCHECK_GE(len, 0);
diff --git a/be/src/gutil/strings/join.cc b/be/src/gutil/strings/join.cc
index e37d16352..b831c61dd 100644
--- a/be/src/gutil/strings/join.cc
+++ b/be/src/gutil/strings/join.cc
@@ -2,12 +2,15 @@
#include "gutil/strings/join.h"
+#include <memory>
+
#include <common/logging.h>
#include "gutil/logging-inl.h"
-#include "gutil/gscoped_ptr.h"
#include "gutil/strings/ascii_ctype.h"
#include "gutil/strings/escaping.h"
+using std::unique_ptr;
+
// ----------------------------------------------------------------------
// JoinUsing()
// This merges a vector of string components with delim inserted
@@ -179,7 +182,7 @@ void JoinCSVLineWithDelimiter(const vector<string>& cols, char delimiter,
// Double the original size, for escaping, plus two bytes for
// the bracketing double-quotes, and one byte for the closing \0.
int size = 2 * col.size() + 3;
- gscoped_array<char> buf(new char[size]);
+ unique_ptr<char[]> buf(new char[size]);
// Leave space at beginning and end for bracketing double-quotes.
int escaped_size = strings::EscapeStrForCSV(col.c_str(),
diff --git a/be/src/gutil/strings/strcat.cc b/be/src/gutil/strings/strcat.cc
index b91fab9f4..2bb8b9966 100644
--- a/be/src/gutil/strings/strcat.cc
+++ b/be/src/gutil/strings/strcat.cc
@@ -9,7 +9,6 @@
#include <common/logging.h>
#include "gutil/logging-inl.h"
-#include "gutil/gscoped_ptr.h"
#include "gutil/strings/ascii_ctype.h"
#include "gutil/strings/escaping.h"
#include "gutil/stl_util.h"
diff --git a/be/src/rpc/impala-service-pool.cc b/be/src/rpc/impala-service-pool.cc
index c1a597a76..bdc3f3e82 100644
--- a/be/src/rpc/impala-service-pool.cc
+++ b/be/src/rpc/impala-service-pool.cc
@@ -25,7 +25,6 @@
#include "exec/kudu/kudu-util.h"
#include "gutil/strings/numbers.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/gutil/strings/join.h"
#include "kudu/rpc/inbound_call.h"
diff --git a/be/src/rpc/impala-service-pool.h b/be/src/rpc/impala-service-pool.h
index 6354e64d3..8f7d1345e 100644
--- a/be/src/rpc/impala-service-pool.h
+++ b/be/src/rpc/impala-service-pool.h
@@ -22,7 +22,6 @@
#include <vector>
#include "kudu/gutil/macros.h"
-#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/rpc/rpc_service.h"
#include "kudu/rpc/service_queue.h"
diff --git a/be/src/runtime/buffered-tuple-stream-test.cc b/be/src/runtime/buffered-tuple-stream-test.cc
index 80b2069bb..f879e73d9 100644
--- a/be/src/runtime/buffered-tuple-stream-test.cc
+++ b/be/src/runtime/buffered-tuple-stream-test.cc
@@ -25,7 +25,6 @@
#include <string>
#include "codegen/llvm-codegen.h"
-#include "gutil/gscoped_ptr.h"
#include "runtime/buffered-tuple-stream.inline.h"
#include "runtime/query-state.h"
#include "runtime/bufferpool/reservation-tracker.h"
@@ -47,7 +46,6 @@
#include "common/names.h"
-using kudu::FreeDeleter;
using std::numeric_limits;
static const int BATCH_SIZE = 250;
@@ -73,6 +71,14 @@ static const StringValue STRINGS[] = {
static const int NUM_STRINGS = sizeof(STRINGS) / sizeof(StringValue);
+// Function object which invokes 'free' on its parameter, which must be
+// a pointer. Can be used to store malloc-allocated pointers in unique_ptr
+struct FreeDeleter {
+ inline void operator()(void* ptr) const {
+ free(ptr);
+ }
+};
+
class SimpleTupleStreamTest : public testing::Test {
protected:
virtual void SetUp() {}
@@ -1967,13 +1973,13 @@ TEST_F(MultiNullableTupleStreamTest, TestComputeRowSize) {
BufferedTupleStream stream(
runtime_state_, string_desc_, &client_, PAGE_LEN, PAGE_LEN, external_slots);
- gscoped_ptr<TupleRow, FreeDeleter> row(
+ unique_ptr<TupleRow, FreeDeleter> row(
reinterpret_cast<TupleRow*>(malloc(tuple_descs.size() * sizeof(Tuple*))));
- gscoped_ptr<Tuple, FreeDeleter> tuple0(
+ unique_ptr<Tuple, FreeDeleter> tuple0(
reinterpret_cast<Tuple*>(malloc(tuple_descs[0]->byte_size())));
- gscoped_ptr<Tuple, FreeDeleter> tuple1(
+ unique_ptr<Tuple, FreeDeleter> tuple1(
reinterpret_cast<Tuple*>(malloc(tuple_descs[1]->byte_size())));
- gscoped_ptr<Tuple, FreeDeleter> tuple2(
+ unique_ptr<Tuple, FreeDeleter> tuple2(
reinterpret_cast<Tuple*>(malloc(tuple_descs[2]->byte_size())));
memset(tuple0.get(), 0, tuple_descs[0]->byte_size());
memset(tuple1.get(), 0, tuple_descs[1]->byte_size());
@@ -2032,11 +2038,11 @@ TEST_F(ArrayTupleStreamTest, TestArrayDeepCopy) {
const int tuple_null_indicator_bytes = 1; // Need 1 bytes for 2 tuples.
int expected_row_size = tuple_null_indicator_bytes + tuple_descs[0]->byte_size()
+ tuple_descs[1]->byte_size();
- gscoped_ptr<TupleRow, FreeDeleter> row(
+ unique_ptr<TupleRow, FreeDeleter> row(
reinterpret_cast<TupleRow*>(malloc(tuple_descs.size() * sizeof(Tuple*))));
- gscoped_ptr<Tuple, FreeDeleter> tuple0(
+ unique_ptr<Tuple, FreeDeleter> tuple0(
reinterpret_cast<Tuple*>(malloc(tuple_descs[0]->byte_size())));
- gscoped_ptr<Tuple, FreeDeleter> tuple1(
+ unique_ptr<Tuple, FreeDeleter> tuple1(
reinterpret_cast<Tuple*>(malloc(tuple_descs[1]->byte_size())));
memset(tuple0.get(), 0, tuple_descs[0]->byte_size());
memset(tuple1.get(), 0, tuple_descs[1]->byte_size());
@@ -2131,11 +2137,11 @@ TEST_F(ArrayTupleStreamTest, TestComputeRowSize) {
BufferedTupleStream stream(
runtime_state_, array_desc_, &client_, PAGE_LEN, PAGE_LEN, external_slots);
- gscoped_ptr<TupleRow, FreeDeleter> row(
+ unique_ptr<TupleRow, FreeDeleter> row(
reinterpret_cast<TupleRow*>(malloc(tuple_descs.size() * sizeof(Tuple*))));
- gscoped_ptr<Tuple, FreeDeleter> tuple0(
+ unique_ptr<Tuple, FreeDeleter> tuple0(
reinterpret_cast<Tuple*>(malloc(tuple_descs[0]->byte_size())));
- gscoped_ptr<Tuple, FreeDeleter> tuple1(
+ unique_ptr<Tuple, FreeDeleter> tuple1(
reinterpret_cast<Tuple*>(malloc(tuple_descs[1]->byte_size())));
memset(tuple0.get(), 0, tuple_descs[0]->byte_size());
memset(tuple1.get(), 0, tuple_descs[1]->byte_size());
diff --git a/be/src/util/hdr-histogram.h b/be/src/util/hdr-histogram.h
index ba479adee..b628cf1a5 100644
--- a/be/src/util/hdr-histogram.h
+++ b/be/src/util/hdr-histogram.h
@@ -44,10 +44,11 @@
// (or better).
#include <stdint.h>
+#include <memory>
#include <vector>
#include <gutil/atomicops.h>
-#include <gutil/gscoped_ptr.h>
+#include <gutil/macros.h>
namespace impala {
@@ -189,7 +190,7 @@ class HdrHistogram {
base::subtle::Atomic64 total_sum_;
base::subtle::Atomic64 min_value_;
base::subtle::Atomic64 max_value_;
- gscoped_array<base::subtle::Atomic64> counts_;
+ std::unique_ptr<base::subtle::Atomic64[]> counts_;
HdrHistogram& operator=(const HdrHistogram& other); // Disable assignment operator.
};