From da020c0641e4fcc06f623616de4bad5331c56342 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 19 Jun 2022 15:38:13 -0700 Subject: [PATCH] Remove some stuff from global_safety.h These bits were unused and/or unnecessary. --- src/global_safety.h | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/src/global_safety.h b/src/global_safety.h index 7230098c1..8667c722b 100644 --- a/src/global_safety.h +++ b/src/global_safety.h @@ -9,42 +9,8 @@ #include "common.h" -// fish is multithreaded. Global (which includes function and file-level statics) when used naively -// may therefore lead to data races. Use the following types to characterize and enforce correct -// access patterns. - -/// A mainthread_t variable may only be accessed on the main thread. -template -class mainthread_t : noncopyable_t { - T value_{}; - - public: - mainthread_t(T value) : value_(std::move(value)) {} - mainthread_t() = default; - - T *operator->() { - ASSERT_IS_MAIN_THREAD(); - return &value_; - } - - operator T &() { - ASSERT_IS_MAIN_THREAD(); - return value_; - } - - operator const T &() const { - ASSERT_IS_MAIN_THREAD(); - return value_; - } - - void operator=(T value) { - ASSERT_IS_MAIN_THREAD(); - value_ = std::move(value); - } -}; - -/// A latch variable may only be set once, on the main thread. -/// The value is a immortal. +/// A latch variable may only be set once. +/// The value is immortal. template class latch_t : noncopyable_t, nonmovable_t { T *value_{}; @@ -57,7 +23,6 @@ class latch_t : noncopyable_t, nonmovable_t { const T *operator->() const { return value_; } void operator=(std::unique_ptr value) { - ASSERT_IS_MAIN_THREAD(); assert(value_ == nullptr && "Latch variable initialized multiple times"); assert(value != nullptr && "Latch variable initialized with null"); // Note: deliberate leak. @@ -65,11 +30,6 @@ class latch_t : noncopyable_t, nonmovable_t { } void operator=(T &&value) { *this = make_unique(std::move(value)); } - - template - void emplace(Args &&...args) { - *this = make_unique(std::forward(args)...); - } }; /// An atomic type that always use relaxed reads.