Signed-off-by: Vincent Biret <vibiret@microsoft.com>
This commit is contained in:
Vincent Biret 2024-05-20 15:11:36 -04:00
Родитель 43f12f4db6
Коммит 999323058a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 32426322EDFFB7E3
1 изменённых файлов: 5 добавлений и 24 удалений

Просмотреть файл

@ -3,13 +3,10 @@ using System.Threading;
namespace Kiota.Builder;
public class ModelClassBuildLifecycle : IDisposable
internal sealed class ModelClassBuildLifecycle : IDisposable
{
private readonly CountdownEvent propertiesBuilt = new(1);
public ModelClassBuildLifecycle()
{
}
public Boolean IsPropertiesBuilt()
public bool IsPropertiesBuilt()
{
return propertiesBuilt.IsSet;
}
@ -26,31 +23,15 @@ public class ModelClassBuildLifecycle : IDisposable
}
public void PropertiesBuildingDone()
{
if (!IsPropertiesBuilt())
{
if (!propertiesBuilt.Signal())
if (!IsPropertiesBuilt() && !propertiesBuilt.Signal())
{
throw new InvalidOperationException("PropertiesBuilt CountdownEvent is expected to always reach 0 at this point.");
}
}
Monitor.Exit(propertiesBuilt);
}
private bool isDisposed;
public void Dispose()
{
Dispose(true);
propertiesBuilt.Dispose();
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (isDisposed) return;
if (disposing)
{
// free managed resources
propertiesBuilt.Dispose();
}
isDisposed = true;
}
}