Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
ensure that reader/writer/commandtx/commandrx objects are set to not …
Browse files Browse the repository at this point in the history
…valid when unavailable
  • Loading branch information
Jamie Brynes committed Feb 19, 2020
1 parent 1d48075 commit ac1c8c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ public override Subscription<T> Subscribe(EntityId entityId)
public override void Cancel(ISubscription subscription)
{
var sub = ((Subscription<T>) subscription);
if (sub.HasValue)
{
var sender = sub.Value;
sender.IsValid = false;
}
ResetValue(sub);

var subscriptions = entityIdToSenderSubscriptions[sub.EntityId];
subscriptions.Remove(sub);
Expand All @@ -122,7 +118,8 @@ public override void ResetValue(ISubscription subscription)
var sub = ((Subscription<T>) subscription);
if (sub.HasValue)
{
sub.Value.RemoveAllCallbacks();
var sender = sub.Value;
sender.IsValid = false;
}
}
}
Expand Down Expand Up @@ -222,12 +219,7 @@ public override Subscription<T> Subscribe(EntityId entityId)
public override void Cancel(ISubscription subscription)
{
var sub = ((Subscription<T>) subscription);
if (sub.HasValue)
{
var receiver = sub.Value;
receiver.IsValid = false;
receiver.RemoveAllCallbacks();
}
ResetValue(sub);

var subscriptions = entityIdToReceiveSubscriptions[sub.EntityId];
subscriptions.Remove(sub);
Expand All @@ -244,7 +236,9 @@ public override void ResetValue(ISubscription subscription)
var sub = ((Subscription<T>) subscription);
if (sub.HasValue)
{
sub.Value.RemoveAllCallbacks();
var receiver = sub.Value;
receiver.IsValid = false;
receiver.RemoveAllCallbacks();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ private static TypeBlock GenerateComponentReaderSubscriptionManager(UnityCompone
public override void Cancel(ISubscription subscription)
{{
var sub = ((Subscription<{componentDetails.Name}Reader>) subscription);
if (sub.HasValue)
{{
var reader = sub.Value;
reader.IsValid = false;
reader.RemoveAllCallbacks();
}}
ResetValue(sub);
var subscriptions = entityIdToReaderSubscriptions[sub.EntityId];
subscriptions.Remove(sub);
Expand All @@ -151,7 +146,9 @@ public override void ResetValue(ISubscription subscription)
var sub = ((Subscription<{componentDetails.Name}Reader>) subscription);
if (sub.HasValue)
{{
sub.Value.RemoveAllCallbacks();
var reader = sub.Value;
reader.IsValid = false;
reader.RemoveAllCallbacks();
}}
}}
Expand Down Expand Up @@ -262,12 +259,7 @@ private static TypeBlock GenerateComponentWriterSubscriptionManager(UnityCompone
public override void Cancel(ISubscription subscription)
{{
var sub = ((Subscription<{componentDetails.Name}Writer>) subscription);
if (sub.HasValue)
{{
var reader = sub.Value;
reader.IsValid = false;
reader.RemoveAllCallbacks();
}}
ResetValue(sub);
var subscriptions = entityIdToWriterSubscriptions[sub.EntityId];
subscriptions.Remove(sub);
Expand All @@ -284,7 +276,9 @@ public override void ResetValue(ISubscription subscription)
var sub = ((Subscription<{componentDetails.Name}Writer>) subscription);
if (sub.HasValue)
{{
sub.Value.RemoveAllCallbacks();
var reader = sub.Value;
reader.IsValid = false;
reader.RemoveAllCallbacks();
}}
}}
");
Expand Down

0 comments on commit ac1c8c2

Please sign in to comment.