Replay CultMesh subscriptions per physical session
This commit is contained in:
parent
61257d5a20
commit
6ffb70cb39
3 changed files with 22 additions and 7 deletions
|
|
@ -303,6 +303,7 @@ namespace GameCult.Mesh
|
|||
private readonly TaskCompletionSource<bool> _ready = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly object _subscribeLock = new();
|
||||
private Task? _subscribeTask;
|
||||
private long _subscribedGeneration = -1;
|
||||
private IDisposable? _stateWatch;
|
||||
private bool _disposed;
|
||||
|
||||
|
|
@ -337,7 +338,9 @@ namespace GameCult.Mesh
|
|||
{
|
||||
lock (_subscribeLock)
|
||||
{
|
||||
if (_subscribeTask is { IsCompleted: false }) return _subscribeTask;
|
||||
var generation = _session.PhysicalGeneration;
|
||||
if (_subscribedGeneration == generation && _subscribeTask != null) return _subscribeTask;
|
||||
_subscribedGeneration = generation;
|
||||
return _subscribeTask = SubscribeAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -380,6 +383,7 @@ namespace GameCult.Mesh
|
|||
private readonly TaskCompletionSource<bool> _ready = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly object _subscribeLock = new();
|
||||
private Task? _subscribeTask;
|
||||
private long _subscribedGeneration = -1;
|
||||
private IDisposable? _stateWatch;
|
||||
private bool _disposed;
|
||||
|
||||
|
|
@ -412,7 +416,9 @@ namespace GameCult.Mesh
|
|||
{
|
||||
lock (_subscribeLock)
|
||||
{
|
||||
if (_subscribeTask is { IsCompleted: false }) return _subscribeTask;
|
||||
var generation = _session.PhysicalGeneration;
|
||||
if (_subscribedGeneration == generation && _subscribeTask != null) return _subscribeTask;
|
||||
_subscribedGeneration = generation;
|
||||
return _subscribeTask = SubscribeAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue