/** * @return sibling with shared latch held */ final Node latchSibling() { Node sibling = mSibling; sibling.acquireShared(); return sibling; }
/** * Return root node latched shared. */ private Node latchRootNode() { Node root = mTree.mRoot; root.acquireShared(); return root; }
/** * Return root node latched shared. */ private Node latchRootNode() { Node root = mTree.mRoot; root.acquireShared(); return root; }
/** * Return root node latched shared. */ private Node latchRootNode() { Node root = mTree.mRoot; root.acquireShared(); return root; }
/** * @return sibling with shared latch held */ final Node latchSibling() { Node sibling = mSibling; sibling.acquireShared(); return sibling; }
/** * @return sibling with shared latch held */ final Node latchSibling() { Node sibling = mSibling; sibling.acquireShared(); return sibling; }
/** * Acquire a shared latch on this frame's bound node. * * @return frame node */ final Node acquireShared() { Node node = mNode; while (true) { node.acquireShared(); Node actualNode = mNode; if (actualNode == node) { return actualNode; } node.releaseShared(); node = actualNode; } }
/** * Acquire a shared latch on this frame's bound node. * * @return frame node */ final Node acquireShared() { Node node = mNode; while (true) { node.acquireShared(); Node actualNode = mNode; if (actualNode == node) { return actualNode; } node.releaseShared(); node = actualNode; } }
/** * Acquire a shared latch on this frame's bound node. * * @return frame node */ final Node acquireShared() { Node node = mNode; while (true) { node.acquireShared(); Node actualNode = mNode; if (actualNode == node) { return actualNode; } node.releaseShared(); node = actualNode; } }
@Override public final boolean isClosed() { Node root = mRoot; root.acquireShared(); boolean closed = root.mPage == p_closedTreePage(); root.releaseShared(); return closed; }
@Override public final boolean isClosed() { Node root = mRoot; root.acquireShared(); boolean closed = root.mPage == p_closedTreePage(); root.releaseShared(); return closed; }
@Override public final boolean isClosed() { Node root = mRoot; root.acquireShared(); boolean closed = root.mPage == p_closedTreePage(); root.releaseShared(); return closed; }
/** * @return shared latched node if found; null if not found */ Node nodeMapGetShared(long nodeId) { int hash = Long.hashCode(nodeId); while (true) { Node node = nodeMapGet(nodeId, hash); if (node == null) { return null; } node.acquireShared(); if (nodeId == node.mId) { return node; } node.releaseShared(); } }
/** * @return shared latched node if found; null if not found */ Node nodeMapGetShared(long nodeId) { int hash = Long.hashCode(nodeId); while (true) { Node node = nodeMapGet(nodeId, hash); if (node == null) { return null; } node.acquireShared(); if (nodeId == node.mId) { return node; } node.releaseShared(); } }
/** * Allows a search to continue into a split node by selecting the original node or the * sibling. If the original node is returned, its shared lock is still held. If the * sibling is returned, it will have a shared latch held and the original node's latch * is released. * * @param node node which was split; shared latch must be held * @return original node or sibling */ final Node selectNode(Node node, byte[] key) { Node sibling = mSibling; sibling.acquireShared(); Node left, right; if (mSplitRight) { left = node; right = sibling; } else { left = sibling; right = node; } if (compare(key) < 0) { right.releaseShared(); return left; } else { left.releaseShared(); return right; } }
/** * Allows a search to continue into a split node by selecting the original node or the * sibling. If the original node is returned, its shared lock is still held. If the * sibling is returned, it will have a shared latch held and the original node's latch * is released. * * @param node node which was split; shared latch must be held * @return original node or sibling */ final Node selectNode(Node node, byte[] key) { Node sibling = mSibling; sibling.acquireShared(); Node left, right; if (mSplitRight) { left = node; right = sibling; } else { left = sibling; right = node; } if (compare(key) < 0) { right.releaseShared(); return left; } else { left.releaseShared(); return right; } }
private void cleanupUnreferencedTree(TreeRef ref) throws IOException { Node root = ref.mRoot; root.acquireShared(); try { mOpenTreesLatch.acquireExclusive(); try { LHashTable.ObjEntry<TreeRef> entry = mOpenTreesById.get(ref.mId); if (entry == null || entry.value != ref) { return; } if (ref.mName != null) { mOpenTrees.remove(ref.mName); } mOpenTreesById.remove(ref.mId); root.makeEvictableNow(); if (root.mId != 0) { nodeMapPut(root); } } finally { mOpenTreesLatch.releaseExclusive(); } } finally { root.releaseShared(); } }
private void cleanupUnreferencedTree(TreeRef ref) throws IOException { Node root = ref.mRoot; root.acquireShared(); try { mOpenTreesLatch.acquireExclusive(); try { LHashTable.ObjEntry<TreeRef> entry = mOpenTreesById.get(ref.mId); if (entry == null || entry.value != ref) { return; } if (ref.mName != null) { mOpenTrees.remove(ref.mName); } mOpenTreesById.remove(ref.mId); root.makeEvictableNow(); if (root.mId != 0) { nodeMapPut(root); } } finally { mOpenTreesLatch.releaseExclusive(); } } finally { root.releaseShared(); } }
private void cleanupUnreferencedTree(TreeRef ref) throws IOException { Node root = ref.mRoot; root.acquireShared(); try { mOpenTreesLatch.acquireExclusive(); try { LHashTable.ObjEntry<TreeRef> entry = mOpenTreesById.get(ref.mId); if (entry == null || entry.value != ref) { return; } if (ref.mName != null) { mOpenTrees.remove(ref.mName); } mOpenTreesById.remove(ref.mId); root.makeEvictableNow(); if (root.mId != 0) { nodeMapPut(root); } } finally { mOpenTreesLatch.releaseExclusive(); } } finally { root.releaseShared(); } }
private static boolean isEmpty(Tree tree) { Node root = tree.mRoot; root.acquireShared(); boolean empty = root.isLeaf() && !root.hasKeys(); root.releaseShared(); if (!empty) { // Double check with a cursor. Tree might be composed of many empty leaf nodes. TreeCursor c = tree.newCursor(Transaction.BOGUS); try { c.mKeyOnly = true; c.first(); empty = c.key() == null; } catch (Throwable e) { // Ignore and keep using the tree for now. } finally { c.reset(); } } return empty; } }