You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by dm...@apache.org on 2014/11/12 20:51:39 UTC

[2/2] mesos git commit: Introduce enable_shared_from_this configure check

Introduce enable_shared_from_this configure check

* Introduce enable_shared_from_this to the configure check
* Document availability of enable_shared_from_this in style guide

Review: https://reviews.apache.org/r/27356


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b930d5ce
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b930d5ce
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b930d5ce

Branch: refs/heads/master
Commit: b930d5ce32b60b7c126844a3ef6ae119d36bc8d0
Parents: 9ce7eca
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Wed Nov 12 11:50:24 2014 -0800
Committer: Dominic Hamon <dh...@twitter.com>
Committed: Wed Nov 12 11:50:46 2014 -0800

----------------------------------------------------------------------
 docs/mesos-c++-style-guide.md  |  3 +++
 m4/ax_cxx_compile_stdcxx_11.m4 | 13 +++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b930d5ce/docs/mesos-c++-style-guide.md
----------------------------------------------------------------------
diff --git a/docs/mesos-c++-style-guide.md b/docs/mesos-c++-style-guide.md
index dfdde85..3cc9ecd 100644
--- a/docs/mesos-c++-style-guide.md
+++ b/docs/mesos-c++-style-guide.md
@@ -112,3 +112,6 @@ Try<Owned<LocalAuthorizer>> authorizer = LocalAuthorizer::create();
     * std::mutex.
     * std::lock_guard<std::mutex>.
     * std::unique_lock<std::mutex>.
+* Shared from this.
+    * class T : public std::enable_shared_from_this<T>.
+    * shared_from_this().

http://git-wip-us.apache.org/repos/asf/mesos/blob/b930d5ce/m4/ax_cxx_compile_stdcxx_11.m4
----------------------------------------------------------------------
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
index 96f87ea..d166aa1 100644
--- a/m4/ax_cxx_compile_stdcxx_11.m4
+++ b/m4/ax_cxx_compile_stdcxx_11.m4
@@ -92,6 +92,19 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
       // end scope of uniqueLock.
     }
   }
+
+  // check for std::enable_shared_from_this.
+  struct SharedStruct : public std::enable_shared_from_this<SharedStruct>
+  {
+    std::shared_ptr<SharedStruct> get()
+    {
+      return shared_from_this();
+    }
+  };
+
+  // construct a new shared_ptr using shared_from_this().
+  std::shared_ptr<SharedStruct> object =
+    std::shared_ptr<SharedStruct>(new SharedStruct())->get();
 ])
 
 AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [