Skip to content

Instantly share code, notes, and snippets.

@chrisnas
Created January 13, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisnas/4d333f56f85aaaf9776beea7d295b81a to your computer and use it in GitHub Desktop.
Save chrisnas/4d333f56f85aaaf9776beea7d295b81a to your computer and use it in GitHub Desktop.
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