LLDB mainline
SystemLifetimeManager.cpp
Go to the documentation of this file.
1//===-- SystemLifetimeManager.cpp -----------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
12
13#include <utility>
14
15using namespace lldb_private;
16
18
20 assert(m_initialized != 0 &&
21 "SystemLifetimeManager destroyed without calling Initialize!");
22 assert(m_initialized == m_terminated &&
23 "SystemLifetimeManager destroyed without calling Terminate!");
24}
25
27 std::unique_ptr<SystemInitializer> initializer) {
28 std::lock_guard<std::recursive_mutex> guard(m_mutex);
29 if (!m_initializer) {
31 m_initializer = std::move(initializer);
32
33 if (auto e = m_initializer->Initialize())
34 return e;
35 }
36
37 return llvm::Error::success();
38}
39
41 std::lock_guard<std::recursive_mutex> guard(m_mutex);
42
43 if (m_initializer) {
44 m_initializer->Terminate();
45 m_initializer.reset();
47 }
48}
llvm::Error Initialize(std::unique_ptr< SystemInitializer > initializer)
std::unique_ptr< SystemInitializer > m_initializer
A class that represents a running process on the host machine.