@@ -103,7 +103,7 @@ public int GetNumRecentlyUsed(TimeSpan recencyPeriod)
103103 /// </param>
104104 public void ScheduleCollection ( ICollectibleGrainContext item , TimeSpan timeout , DateTime now )
105105 {
106- lock ( item )
106+ lock ( ActivationData . GetSynchronizationLock ( item ) )
107107 {
108108 if ( item . IsExemptFromCollection )
109109 {
@@ -131,7 +131,7 @@ public bool TryCancelCollection(ICollectibleGrainContext item)
131131 if ( item is null ) return false ;
132132 if ( item . IsExemptFromCollection ) return false ;
133133
134- lock ( item )
134+ lock ( ActivationData . GetSynchronizationLock ( item ) )
135135 {
136136 DateTime ticket = item . CollectionTicket ;
137137 if ( default == ticket ) return false ;
@@ -154,7 +154,7 @@ public bool TryRescheduleCollection(ICollectibleGrainContext item)
154154 {
155155 if ( item . IsExemptFromCollection ) return false ;
156156
157- lock ( item )
157+ lock ( ActivationData . GetSynchronizationLock ( item ) )
158158 {
159159 if ( TryRescheduleCollection_Impl ( item , item . CollectionAgeLimit ) ) return true ;
160160
@@ -236,7 +236,7 @@ public List<ICollectibleGrainContext> ScanStale()
236236 // If the activation is to be reactivated, it's our job to clear the activation's copy of the ticket.
237237 foreach ( var activation in activations )
238238 {
239- lock ( activation )
239+ lock ( ActivationData . GetSynchronizationLock ( activation ) )
240240 {
241241 activation . CollectionTicket = default ;
242242 if ( ! activation . IsValid )
@@ -283,7 +283,7 @@ public List<ICollectibleGrainContext> ScanAll(TimeSpan ageLimit)
283283 foreach ( var kvp in bucket . Items )
284284 {
285285 var activation = kvp . Value ;
286- lock ( activation )
286+ lock ( ActivationData . GetSynchronizationLock ( activation ) )
287287 {
288288 if ( ! activation . IsValid )
289289 {
@@ -691,7 +691,7 @@ public void Add(ICollectibleGrainContext item)
691691
692692 public bool TryRemove ( ICollectibleGrainContext item )
693693 {
694- lock ( item )
694+ lock ( ActivationData . GetSynchronizationLock ( item ) )
695695 {
696696 if ( item . CollectionTicket == default )
697697 {
@@ -711,7 +711,7 @@ public List<ICollectibleGrainContext> CancelAll()
711711 {
712712 // Attempt to cancel the item. if we succeed, it wasn't already cancelled and we can return it. otherwise, we silently ignore it.
713713 var item = pair . Value ;
714- lock ( item )
714+ lock ( ActivationData . GetSynchronizationLock ( item ) )
715715 {
716716 if ( item . CollectionTicket == default )
717717 {
0 commit comments