Chromium Code Reviews| Index: src/IceDefs.h |
| diff --git a/src/IceDefs.h b/src/IceDefs.h |
| index 5893ef43d8408fe6f4b79bdf9707d39ba20b197b..344d0eac45e94e7af75009bac789a6cd97cff81b 100644 |
| --- a/src/IceDefs.h |
| +++ b/src/IceDefs.h |
| @@ -119,7 +119,6 @@ static std::unique_ptr<T> makeUnique(Args &&... TheArgs) { |
| #define ENABLE_MAKE_UNIQUE friend struct ::Ice::Internal::MakeUniqueEnabler |
| -using IceString = std::string; |
| using InstList = llvm::ilist<Inst>; |
| // Ideally PhiList would be llvm::ilist<InstPhi>, and similar for AssignList, |
| // but this runs into issues with SFINAE. |
| @@ -357,6 +356,29 @@ using Fdstream = llvm::raw_fd_ostream; |
| using GlobalLockType = std::mutex; |
| +template <typename T> class LockedPtr { |
|
John
2016/03/29 14:23:15
Consider documenting locked ptr.
Jim Stichnoth
2016/03/29 21:40:49
Done.
|
| + LockedPtr() = delete; |
| + LockedPtr(const LockedPtr &) = delete; |
| + LockedPtr &operator=(const LockedPtr &) = delete; |
| + |
| +public: |
| + LockedPtr(T *Value, GlobalLockType *Lock) : Value(Value), Lock(Lock) { |
| + Lock->lock(); |
| + } |
| + LockedPtr(LockedPtr &&Other) : Value(Other.Value), Lock(Other.Lock) { |
| + Other.Value = nullptr; |
| + Other.Lock = nullptr; |
| + } |
| + ~LockedPtr() { Lock->unlock(); } |
| + T *operator->() const { return Value; } |
| + T &operator*() const { return *Value; } |
| + T *get() { return Value; } |
| + |
| +private: |
| + T *Value; |
| + GlobalLockType *Lock; |
| +}; |
| + |
| enum ErrorCodes { EC_None = 0, EC_Args, EC_Bitcode, EC_Translation }; |
| /// Wrapper around std::error_code for allowing multiple errors to be folded |