winmr-api/Utils/ConcurrentObject.cs

21 lines
484 B
C#
Raw Normal View History

2025-07-04 00:04:51 +03:00
/* This software is licensed by the MIT License, see LICENSE file */
/* Copyright © 2024-2025 Gregory Lirent */
2025-07-02 16:06:50 +03:00
2025-07-03 15:22:40 +03:00
namespace WebmrAPI.Utils
2025-07-02 16:06:50 +03:00
{
2025-07-03 15:22:40 +03:00
public class ConcurrentObject
2025-07-02 16:06:50 +03:00
{
internal readonly object _lock = new object();
public void LockedSet<T>(ref T dst, T value)
{
lock (_lock) dst = value;
}
public T LockedGet<T>(ref T src)
{
lock (_lock) return src;
}
}
}