less locks on AddVolumeElement

This commit is contained in:
Joachim Schöberl 2019-09-23 21:50:42 +02:00
parent f008de5b04
commit d995976621

View File

@ -332,9 +332,6 @@ namespace netgen
ElementIndex Mesh :: AddVolumeElement (const Element & el) ElementIndex Mesh :: AddVolumeElement (const Element & el)
{ {
NgLock lock(mutex);
lock.Lock();
/* /*
int maxn = el[0]; int maxn = el[0];
for (int i = 1; i < el.GetNP(); i++) for (int i = 1; i < el.GetNP(); i++)
@ -362,7 +359,17 @@ namespace netgen
int ve = volelements.Size(); int ve = volelements.Size();
volelements.Append (el); if (volelements.Size() == volelements.AllocSize())
{
NgLock lock(mutex);
lock.Lock();
volelements.Append (el);
lock.UnLock();
}
else
{
volelements.Append (el);
}
volelements.Last().flags.illegal_valid = 0; volelements.Last().flags.illegal_valid = 0;
// while (volelements.Size() > eltyps.Size()) // while (volelements.Size() > eltyps.Size())
@ -370,7 +377,6 @@ namespace netgen
timestamp = NextTimeStamp(); timestamp = NextTimeStamp();
lock.UnLock();
return ve; return ve;
} }