···11// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22// See the LICENCE file in the repository root for full licence text.
3344-using osu.Framework.Graphics.OpenGL;
54using System;
65using System.Runtime.CompilerServices;
66+using System.Threading;
77using osu.Framework.Graphics.Batches;
88using osu.Framework.Graphics.Colour;
99+using osu.Framework.Graphics.OpenGL;
910using osu.Framework.Graphics.OpenGL.Buffers;
1011using osu.Framework.Graphics.OpenGL.Textures;
1112using osu.Framework.Graphics.OpenGL.Vertices;
1213using osu.Framework.Graphics.Primitives;
1314using osu.Framework.Graphics.Textures;
1414-using osu.Framework.Threading;
1515using osu.Framework.Utils;
1616using osuTK;
1717···4545 /// </summary>
4646 protected IDrawable Source { get; private set; }
47474848- private readonly AtomicCounter referenceCount = new AtomicCounter();
4848+ private long referenceCount;
49495050 /// <summary>
5151 /// The depth at which drawing should take place.
···282282 /// <remarks>
283283 /// All <see cref="DrawNode"/>s start with a reference count of 1.
284284 /// </remarks>
285285- internal void Reference() => referenceCount.Increment();
285285+ internal void Reference() => Interlocked.Increment(ref referenceCount);
286286287287 protected internal bool IsDisposed { get; private set; }
288288289289 public void Dispose()
290290 {
291291- if (referenceCount.Decrement() != 0)
291291+ if (Interlocked.Decrement(ref referenceCount) != 0)
292292 return;
293293294294 GLWrapper.ScheduleDisposal(() => Dispose(true));
-26
osu.Framework/Threading/AtomicCounter.cs
···11-// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
22-// See the LICENCE file in the repository root for full licence text.
33-44-using System.Threading;
55-66-namespace osu.Framework.Threading
77-{
88- public class AtomicCounter
99- {
1010- private long count;
1111-1212- public long Increment() => Interlocked.Increment(ref count);
1313-1414- public long Decrement() => Interlocked.Decrement(ref count);
1515-1616- public long Add(long value) => Interlocked.Add(ref count, value);
1717-1818- public long Reset() => Interlocked.Exchange(ref count, 0);
1919-2020- public long Value
2121- {
2222- set => Interlocked.Exchange(ref count, value);
2323- get => Interlocked.Read(ref count);
2424- }
2525- }
2626-}