#include <stddef.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/at_exit.h"
#include "base/atomic_sequence_num.h"
#include "base/atomicops.h"
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/memory/aligned_memory.h"
#include "base/memory/raw_ptr.h"
#include "base/system/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/threading/simple_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
base::AtomicSequenceNumber constructed_seq_;
base::AtomicSequenceNumber destructed_seq_;
class ConstructAndDestructLogger { … };
class SlowConstructor { … };
int SlowConstructor::constructed = …;
class SlowDelegate : public base::DelegateSimpleThread::Delegate { … };
}
base::LazyInstance<ConstructAndDestructLogger>::DestructorAtExit lazy_logger = …;
TEST(LazyInstanceTest, Basic) { … }
base::LazyInstance<SlowConstructor>::DestructorAtExit lazy_slow = …;
TEST(LazyInstanceTest, ConstructorThreadSafety) { … }
namespace {
class DeleteLogger { … };
}
TEST(LazyInstanceTest, LeakyLazyInstance) { … }
namespace {
template <size_t alignment>
class AlignedData { … };
}
TEST(LazyInstanceTest, Alignment) { … }
namespace {
class BlockingConstructor { … };
class BlockingConstructorThread : public base::SimpleThread { … };
base::subtle::Atomic32 BlockingConstructor::constructor_called_ = …;
base::subtle::Atomic32 BlockingConstructor::complete_construction_ = …;
base::LazyInstance<BlockingConstructor>::DestructorAtExit lazy_blocking = …;
}
TEST(LazyInstanceTest, PriorityInversionAtInitializationResolves) { … }