mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 16:07:25 +08:00
aa68ae4ff2
Was required to lock over `await` calls server-side.
25 lines
597 B
C#
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);
|
|
}
|
|
}
|
|
}
|