Copy Aetheria Code
Added a bunch of code from the old Aetheria project
This commit is contained in:
parent
ab392cd3d6
commit
c58ba0b1da
1704 changed files with 175081 additions and 313 deletions
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace UniRx
|
||||
{
|
||||
public sealed class ScheduledDisposable : ICancelable
|
||||
{
|
||||
private readonly IScheduler scheduler;
|
||||
private volatile IDisposable disposable;
|
||||
private int isDisposed = 0;
|
||||
|
||||
public ScheduledDisposable(IScheduler scheduler, IDisposable disposable)
|
||||
{
|
||||
this.scheduler = scheduler;
|
||||
this.disposable = disposable;
|
||||
}
|
||||
|
||||
public IScheduler Scheduler
|
||||
{
|
||||
get { return scheduler; }
|
||||
}
|
||||
|
||||
public IDisposable Disposable
|
||||
{
|
||||
get { return disposable; }
|
||||
}
|
||||
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return isDisposed != 0; }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Scheduler.Schedule(DisposeInner);
|
||||
}
|
||||
|
||||
private void DisposeInner()
|
||||
{
|
||||
if (Interlocked.Increment(ref isDisposed) == 1)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue