@@ -43,6 +43,8 @@ SharedMemoryBlockManager::CpuCreate(
43
43
{
44
44
*smb = nullptr ;
45
45
46
+ std::lock_guard<std::mutex> lock (mu_);
47
+
46
48
if (blocks_.find (name) != blocks_.end ()) {
47
49
return TRTSERVER_ErrorNew (
48
50
TRTSERVER_ERROR_ALREADY_EXISTS,
@@ -67,6 +69,8 @@ SharedMemoryBlockManager::GpuCreate(
67
69
{
68
70
*smb = nullptr ;
69
71
72
+ std::lock_guard<std::mutex> lock (mu_);
73
+
70
74
if (blocks_.find (name) != blocks_.end ()) {
71
75
return TRTSERVER_ErrorNew (
72
76
TRTSERVER_ERROR_ALREADY_EXISTS,
@@ -89,6 +93,8 @@ SharedMemoryBlockManager::Get(
89
93
{
90
94
*smb = nullptr ;
91
95
96
+ std::lock_guard<std::mutex> lock (mu_);
97
+
92
98
auto itr = blocks_.find (name);
93
99
if (itr == blocks_.end ()) {
94
100
return TRTSERVER_ErrorNew (
@@ -108,6 +114,8 @@ SharedMemoryBlockManager::Find(
108
114
{
109
115
*smb = nullptr ;
110
116
117
+ std::lock_guard<std::mutex> lock (mu_);
118
+
111
119
auto itr = blocks_.find (name);
112
120
if (itr != blocks_.end ()) {
113
121
*smb = itr->second ;
@@ -122,6 +130,8 @@ SharedMemoryBlockManager::Remove(
122
130
{
123
131
*smb = nullptr ;
124
132
133
+ std::lock_guard<std::mutex> lock (mu_);
134
+
125
135
auto itr = blocks_.find (name);
126
136
if (itr != blocks_.end ()) {
127
137
*smb = itr->second ;
@@ -136,6 +146,8 @@ SharedMemoryBlockManager::Clear()
136
146
{
137
147
std::string failed_blocks;
138
148
149
+ std::lock_guard<std::mutex> lock (mu_);
150
+
139
151
auto it = blocks_.begin ();
140
152
while (it != blocks_.cend ()) {
141
153
TRTSERVER_Error* err = TRTSERVER_SharedMemoryBlockDelete (it->second );
0 commit comments