Skip to content

Instantly share code, notes, and snippets.

View YairHalberstadt's full-sized avatar

Yair Halberstadt YairHalberstadt

View GitHub Profile
@YairHalberstadt
YairHalberstadt / AtomicReference.cs
Last active December 10, 2019 19:34
AtomicReference In C#
using System;
public class AtomicReference<T>
{
private object _lock = new object();
private T _value;
public AtomicReference(T value) => _value = value;
public void LockedUpdate(Func<T,T> updateFunc)
{
lock(_lock)
{