9#ifndef LLDB_UTILITY_SHAREDCLUSTER_H
10#define LLDB_UTILITY_SHAREDCLUSTER_H
13#include "llvm/ADT/STLExtras.h"
14#include "llvm/ADT/SmallPtrSet.h"
22class ClusterManager :
public std::enable_shared_from_this<ClusterManager<T>> {
24 static std::shared_ptr<ClusterManager>
Create() {
34 std::lock_guard<std::mutex> guard(
m_mutex);
36 assert(ret.second &&
"ManageObject called twice for the same object?");
41 std::lock_guard<std::mutex> guard(
m_mutex);
42 auto this_sp = this->shared_from_this();
43 size_t count =
m_objects.count(desired_object);
45 lldbassert(
false &&
"object not found in shared cluster when expected");
46 desired_object =
nullptr;
48 return {std::move(this_sp), desired_object};
std::shared_ptr< T > GetSharedPointer(T *desired_object)
llvm::SmallPtrSet< T *, 4 > m_objects
void ManageObject(T *new_object)
static std::shared_ptr< ClusterManager > Create()
A class that represents a running process on the host machine.