Created
January 13, 2019 16:23
-
-
Save chrisnas/4d333f56f85aaaf9776beea7d295b81a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReferenceQueue<T> | |
where T : class | |
{ | |
... | |
internal void Track(T value, PhantomReference<T> reference) | |
{ | |
_table.Add(value, reference); | |
} | |
internal void Untrack(T value) | |
{ | |
if (_table.TryGetValue(value, out var reference)) | |
{ | |
_table.Remove(value); | |
GC.SuppressFinalize(reference); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment