/// <summary>
/// Called by children to this root, when they would like to
/// be unbound, but are (possibly) running in a finalizer thread
/// so it is (possibly) not safe to unbind then directly.
/// </summary>
/// <param name="handleToUnbind">The core handle that is not needed anymore and should be unbound.</param>
private void RequestUnbind(RealmHandle handleToUnbind)
{
lock (_unbindListLock) // You can lock a lock several times inside the same thread. The top-level-lock is the one that counts
{
// first let's see if we should go to the list or not
if (_noMoreUserThread)
{
UnbindLockedList();
handleToUnbind.Unbind();
}
else
{
_unbindList.Add(handleToUnbind); // resurrects handleToUnbind - but it is never a root object bc RequestUnbind is always called above with root.
}
}
}