summaryrefslogtreecommitdiff
path: root/src/mongo/stdx
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-18 17:34:13 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-19 17:00:05 -0400
commite699454322eb5f02cc5ea865421188664382f150 (patch)
tree05e780d075cc12cd42fef033e365bd1f41666197 /src/mongo/stdx
parent95f2a43a398f07121d04af800bacd139eb43d7cd (diff)
downloadmongo-e699454322eb5f02cc5ea865421188664382f150.tar.gz
SERVER-17310 Add polyfills for types from the <thread>, <mutex> and <condition_variable> headers.
Demonstrate usage in mongo/util/concurrency/ticketholder.{h,cpp}.
Diffstat (limited to 'src/mongo/stdx')
-rw-r--r--src/mongo/stdx/condition_variable.h40
-rw-r--r--src/mongo/stdx/mutex.h59
-rw-r--r--src/mongo/stdx/thread.h2
3 files changed, 100 insertions, 1 deletions
diff --git a/src/mongo/stdx/condition_variable.h b/src/mongo/stdx/condition_variable.h
new file mode 100644
index 00000000000..5a494edf5b4
--- /dev/null
+++ b/src/mongo/stdx/condition_variable.h
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include <boost/thread/condition_variable.hpp>
+
+namespace mongo {
+namespace stdx {
+
+ using condition_variable = boost::condition_variable;
+ using cv_status = boost::cv_status;
+
+} // namespace stdx
+} // namespace mongo
diff --git a/src/mongo/stdx/mutex.h b/src/mongo/stdx/mutex.h
new file mode 100644
index 00000000000..b495943b8b1
--- /dev/null
+++ b/src/mongo/stdx/mutex.h
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include <boost/thread/mutex.hpp>
+
+namespace mongo {
+namespace stdx {
+
+ using boost::mutex;
+ using boost::timed_mutex;
+
+ using boost::adopt_lock_t;
+ using boost::defer_lock_t;
+ using boost::try_to_lock_t;
+
+ using boost::lock_guard;
+ using boost::unique_lock;
+
+#if _MSC_VER < 1900
+#define MONGO_STDX_CONSTEXPR const
+#else
+#define MONGO_STDX_CONSTEXPR constexpr
+#endif
+
+ MONGO_STDX_CONSTEXPR adopt_lock_t adopt_lock{};
+ MONGO_STDX_CONSTEXPR defer_lock_t defer_lock{};
+ MONGO_STDX_CONSTEXPR try_to_lock_t try_to_lock{};
+
+#undef MONGO_STDX_CONSTEXPR
+
+} // namespace stdx
+} // namespace mongo
diff --git a/src/mongo/stdx/thread.h b/src/mongo/stdx/thread.h
index 692dfbeb6a1..d38d696d1ff 100644
--- a/src/mongo/stdx/thread.h
+++ b/src/mongo/stdx/thread.h
@@ -33,8 +33,8 @@
namespace mongo {
namespace stdx {
+ using thread = boost::thread;
namespace this_thread = boost::this_thread;
} // namespace stdx
} // namespace mongo
-