UniRx 에셋 추가

This commit is contained in:
Mingu Kim
2025-06-02 00:27:36 +09:00
parent 915f292d7d
commit 8a54d47b56
510 changed files with 42973 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections;
namespace UniRx
{
public sealed class MultipleAssignmentDisposable : IDisposable, ICancelable
{
static readonly BooleanDisposable True = new BooleanDisposable(true);
object gate = new object();
IDisposable current;
public bool IsDisposed
{
get
{
lock (gate)
{
return current == True;
}
}
}
public IDisposable Disposable
{
get
{
lock (gate)
{
return (current == True)
? UniRx.Disposable.Empty
: current;
}
}
set
{
var shouldDispose = false;
lock (gate)
{
shouldDispose = (current == True);
if (!shouldDispose)
{
current = value;
}
}
if (shouldDispose && value != null)
{
value.Dispose();
}
}
}
public void Dispose()
{
IDisposable old = null;
lock (gate)
{
if (current != True)
{
old = current;
current = True;
}
}
if (old != null) old.Dispose();
}
}
}