reset hlsf to single thread
This commit is contained in:
@@ -47,33 +47,32 @@ namespace StgSharp.HighPerformance.Memory
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
AcquireEntrySpinLock(e);
|
||||
try
|
||||
{
|
||||
if (GetEntryState(e) != EntryState.Allocated) {
|
||||
return;
|
||||
}
|
||||
SetEntryState(e, EntryState.ThreadOccupied);
|
||||
|
||||
// Step 4: Try merge with adjacent free blocks and remove them from buckets
|
||||
MergeAndRemoveFromBuckets(e);
|
||||
|
||||
// Step 5: Calculate final level and segment for the merged block
|
||||
uint finalSize = e->Size;
|
||||
int finalLevel = GetLevelFromSize(finalSize);
|
||||
int finalSegment = DetermineSegmentIndex(finalSize, finalLevel);
|
||||
|
||||
// Step 6: Set the merged entry state to Empty (ready to be reused)
|
||||
SetEntryState(e, EntryState.Empty);
|
||||
|
||||
// Step 7: Push the merged entry back to appropriate bucket
|
||||
PushLevel(finalLevel, finalSegment, (BucketNode*)e->Position);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Step 8: Always release the spin lock
|
||||
ReleaseEntrySpinLock(e);
|
||||
if (GetEntryState(e) != EntryState.Allocated) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Set to ThreadOccupied to prevent other operations
|
||||
SetEntryState(e, EntryState.ThreadOccupied);
|
||||
|
||||
|
||||
// Try merge with adjacent free blocks and remove them from buckets
|
||||
MergeAndRemoveFromBuckets(e);
|
||||
|
||||
|
||||
// Calculate final level and segment for the merged block
|
||||
uint finalSize = e->Size;
|
||||
int finalLevel = GetLevelFromSize(finalSize);
|
||||
int finalSegment = DetermineSegmentIndex(finalSize, finalLevel);
|
||||
|
||||
|
||||
// Set the merged entry state to Empty (ready to be reused)
|
||||
SetEntryState(e, EntryState.Empty);
|
||||
|
||||
|
||||
// Push the merged entry back to appropriate bucket
|
||||
PushLevel(finalLevel, finalSegment, (BucketNode*)e->Position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user