1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 22:22:54 +08:00
osu-lazer/osu.Game/Online/RealtimeMultiplayer/LockUntilDisposal.cs
Dean Herbert aa68ae4ff2 Change locking mechanism for multiplayer rooms to use using-disposal pattern
Was required to lock over `await` calls server-side.
2020-12-08 20:43:18 +09:00

25 lines
597 B
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Threading;
namespace osu.Game.Online.RealtimeMultiplayer
{
public readonly struct LockUntilDisposal : IDisposable
{
private readonly object lockTarget;
public LockUntilDisposal(object lockTarget)
{
this.lockTarget = lockTarget;
Monitor.Enter(lockTarget);
}
public void Dispose()
{
Monitor.Exit(lockTarget);
}
}
}