X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=kona%2Fsrc%2Forg%2Fgffs%2Fcache%2FTimeoutList.java;fp=kona%2Fsrc%2Forg%2Fgffs%2Fcache%2FTimeoutList.java;h=c59069bff9b75e0b27eaca77f25592a82adef410;hb=13679382916f379ef7fc0cf02693f0186a905835;hp=0000000000000000000000000000000000000000;hpb=909697fd6009240b5bf2643d54b129b06b733953;p=feisty_meow.git diff --git a/kona/src/org/gffs/cache/TimeoutList.java b/kona/src/org/gffs/cache/TimeoutList.java new file mode 100644 index 00000000..c59069bf --- /dev/null +++ b/kona/src/org/gffs/cache/TimeoutList.java @@ -0,0 +1,56 @@ +package org.gffs.cache; + +/* + * Copyright 2006 University of Virginia + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +class TimeoutList extends CacheList +{ + public TimeoutList() + { + super(RoleBasedCacheNode.ROLE_TIMEOUT); + } + + @Override + public void insert(RoleBasedCacheNode node) + { + // We'll start at the end because most likely we're adding to the end + if (_tail == null) { + // The list is empty + _head = _tail = node; + return; + } + + RoleBasedCacheNode tmp; + for (tmp = _tail; tmp != null; tmp = tmp.getPrevious(_myRole)) { + if (tmp.getInvalidationDate().compareTo(node.getInvalidationDate()) <= 0) { + // current node invalidates before me, so I should go after him + node.setPrevious(_myRole, tmp); + node.setNext(_myRole, tmp.getNext(_myRole)); + tmp.setNext(_myRole, node); + if (node.getNext(_myRole) == null) { + // Adding to the tail + _tail = node; + } else { + node.getNext(_myRole).setPrevious(_myRole, node); + } + + return; + } + } + + // We add to the head of the list + node.setNext(_myRole, _head); + _head.setPrevious(_myRole, node); + _head = node; + } +} \ No newline at end of file