File tree Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ internal class CustomSlotSupplier : NativeInvokeableClass<Interop.CustomSlotSupp
1515 {
1616 private readonly ILogger logger ;
1717 private readonly Temporalio . Worker . Tuning . ICustomSlotSupplier userSupplier ;
18- private readonly Dictionary < uint , GCHandle > permits = new ( ) ;
18+ private readonly Dictionary < uint , Temporalio . Worker . Tuning . ISlotPermit > permits = new ( ) ;
1919 private uint permitId = 1 ;
2020
2121 /// <summary>
@@ -167,11 +167,10 @@ private void Release(Interop.SlotReleaseCtx ctx)
167167
168168 private uint AddPermitToMap ( Temporalio . Worker . Tuning . ISlotPermit permit )
169169 {
170- var handle = GCHandle . Alloc ( permit ) ;
171170 lock ( permits )
172171 {
173172 var usedPermitId = permitId ;
174- permits . Add ( permitId , handle ) ;
173+ permits . Add ( permitId , permit ) ;
175174 permitId += 1 ;
176175 return usedPermitId ;
177176 }
Original file line number Diff line number Diff line change @@ -14,14 +14,11 @@ public class SlotMarkUsedContext
1414 /// Initializes a new instance of the <see cref="SlotMarkUsedContext"/> class.
1515 /// </summary>
1616 /// <param name="ctx">The bridge version of the slot mark used context.</param>
17- /// <param name="userData ">The user data associated with the slot .</param>
18- internal SlotMarkUsedContext ( Temporalio . Bridge . Interop . SlotMarkUsedCtx ctx , GCHandle userData )
17+ /// <param name="permit ">The user-create permit instance .</param>
18+ internal SlotMarkUsedContext ( Temporalio . Bridge . Interop . SlotMarkUsedCtx ctx , ISlotPermit permit )
1919 {
2020 this . SlotInfo = SlotInfo . FromBridge ( ctx . slot_info ) ;
21- unsafe
22- {
23- this . Permit = ( ISlotPermit ) userData . Target ! ;
24- }
21+ this . Permit = permit ;
2522 }
2623
2724 /// <summary>
Original file line number Diff line number Diff line change 1- using System . Runtime . InteropServices ;
2-
31namespace Temporalio . Worker . Tuning
42{
53 /// <summary>
@@ -14,14 +12,14 @@ public class SlotReleaseContext
1412 /// Initializes a new instance of the <see cref="SlotReleaseContext"/> class.
1513 /// </summary>
1614 /// <param name="ctx">The bridge version of the slot release context.</param>
17- /// <param name="userData ">The user data associated with the slot .</param>
18- internal SlotReleaseContext ( Temporalio . Bridge . Interop . SlotReleaseCtx ctx , GCHandle userData )
15+ /// <param name="permit ">The user-create permit instance .</param>
16+ internal SlotReleaseContext ( Temporalio . Bridge . Interop . SlotReleaseCtx ctx , ISlotPermit permit )
1917 {
2018 unsafe
2119 {
2220 this . SlotInfo = ctx . slot_info is null ? null : SlotInfo . FromBridge ( * ctx . slot_info ) ;
23- this . Permit = ( ISlotPermit ) userData . Target ! ;
2421 }
22+ this . Permit = permit ;
2523 }
2624
2725 /// <summary>
You can’t perform that action at this time.
0 commit comments