1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:42:54 +08:00
osu-lazer/osu.Game/Database/ILive.cs

49 lines
1.6 KiB
C#
Raw Normal View History

// 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;
namespace osu.Game.Database
{
/// <summary>
/// A wrapper to provide access to database backed classes in a thread-safe manner.
/// </summary>
/// <typeparam name="T">The databased type.</typeparam>
2021-11-26 13:38:39 +08:00
public interface ILive<T> : IEquatable<ILive<T>>
where T : class // TODO: Add IHasGuidPrimaryKey once we don't need EF support any more.
{
Guid ID { get; }
/// <summary>
/// Perform a read operation on this live object.
/// </summary>
/// <param name="perform">The action to perform.</param>
void PerformRead(Action<T> perform);
/// <summary>
/// Perform a read operation on this live object.
/// </summary>
/// <param name="perform">The action to perform.</param>
TReturn PerformRead<TReturn>(Func<T, TReturn> perform);
/// <summary>
/// Perform a write operation on this live object.
/// </summary>
/// <param name="perform">The action to perform.</param>
void PerformWrite(Action<T> perform);
/// <summary>
/// Whether this instance is tracking data which is managed by the database backing.
/// </summary>
bool IsManaged { get; }
/// <summary>
2021-11-30 10:56:53 +08:00
/// Resolve the value of this instance on the update thread.
/// </summary>
/// <remarks>
2021-11-30 10:56:53 +08:00
/// After resolving, the data should not be passed between threads.
/// </remarks>
T Value { get; }
}
}