aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ExecutionEngine/Orc/RPCSerialization.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ExecutionEngine/Orc/RPCSerialization.h')
-rw-r--r--include/llvm/ExecutionEngine/Orc/RPCSerialization.h93
1 files changed, 27 insertions, 66 deletions
diff --git a/include/llvm/ExecutionEngine/Orc/RPCSerialization.h b/include/llvm/ExecutionEngine/Orc/RPCSerialization.h
index 1e5f6ced597a..07c7471afc6a 100644
--- a/include/llvm/ExecutionEngine/Orc/RPCSerialization.h
+++ b/include/llvm/ExecutionEngine/Orc/RPCSerialization.h
@@ -1,9 +1,8 @@
//===- llvm/ExecutionEngine/Orc/RPCSerialization.h --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -128,123 +127,85 @@ template <typename T>
class RPCTypeName<Expected<T>> {
public:
static const char* getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name) << "Expected<"
<< RPCTypeNameSequence<T>()
<< ">";
+ return Name;
+ }();
return Name.data();
}
-
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename T>
-std::mutex RPCTypeName<Expected<T>>::NameMutex;
-
-template <typename T>
-std::string RPCTypeName<Expected<T>>::Name;
-
template <typename T1, typename T2>
class RPCTypeName<std::pair<T1, T2>> {
public:
static const char* getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name) << "std::pair<" << RPCTypeNameSequence<T1, T2>()
<< ">";
+ return Name;
+ }();
return Name.data();
}
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename T1, typename T2>
-std::mutex RPCTypeName<std::pair<T1, T2>>::NameMutex;
-template <typename T1, typename T2>
-std::string RPCTypeName<std::pair<T1, T2>>::Name;
-
template <typename... ArgTs>
class RPCTypeName<std::tuple<ArgTs...>> {
public:
static const char* getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name) << "std::tuple<"
<< RPCTypeNameSequence<ArgTs...>() << ">";
+ return Name;
+ }();
return Name.data();
}
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename... ArgTs>
-std::mutex RPCTypeName<std::tuple<ArgTs...>>::NameMutex;
-template <typename... ArgTs>
-std::string RPCTypeName<std::tuple<ArgTs...>>::Name;
-
template <typename T>
class RPCTypeName<std::vector<T>> {
public:
static const char*getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name) << "std::vector<" << RPCTypeName<T>::getName()
<< ">";
+ return Name;
+ }();
return Name.data();
}
-
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename T>
-std::mutex RPCTypeName<std::vector<T>>::NameMutex;
-template <typename T>
-std::string RPCTypeName<std::vector<T>>::Name;
-
template <typename T> class RPCTypeName<std::set<T>> {
public:
static const char *getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name)
<< "std::set<" << RPCTypeName<T>::getName() << ">";
+ return Name;
+ }();
return Name.data();
}
-
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename T> std::mutex RPCTypeName<std::set<T>>::NameMutex;
-template <typename T> std::string RPCTypeName<std::set<T>>::Name;
-
template <typename K, typename V> class RPCTypeName<std::map<K, V>> {
public:
static const char *getName() {
- std::lock_guard<std::mutex> Lock(NameMutex);
- if (Name.empty())
+ static std::string Name = [] {
+ std::string Name;
raw_string_ostream(Name)
<< "std::map<" << RPCTypeNameSequence<K, V>() << ">";
+ return Name;
+ }();
return Name.data();
}
-
-private:
- static std::mutex NameMutex;
- static std::string Name;
};
-template <typename K, typename V>
-std::mutex RPCTypeName<std::map<K, V>>::NameMutex;
-template <typename K, typename V> std::string RPCTypeName<std::map<K, V>>::Name;
-
/// The SerializationTraits<ChannelT, T> class describes how to serialize and
/// deserialize an instance of type T to/from an abstract channel of type
/// ChannelT. It also provides a representation of the type's name via the