⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deleter.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// Copyright (C) 2003-@year@, Leo Mekenkamp. All rights reserved.//// $Id: Deleter.java,v 1.1.2.1 2004/03/28 16:40:03 per_nyfelt Exp $package org.ozoneDB.core.storage.gammaStore;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;import java.util.Collections;import java.util.HashSet;import java.util.Iterator;import java.util.LinkedHashMap;import java.util.LinkedHashSet;import java.util.Map;import java.util.Set;import java.util.Map.Entry;import java.util.logging.Level;import java.util.logging.Logger;import org.ozoneDB.OzoneInternalException;/** * <p>Takes care of <code>Storable</code> implemeting instances, in that it * has different threads for serializing and writing to <code>Storage</code>. * <code>Remove()</code> ensures that if a null is * returned that the <code>Storable</code> for the given key has been * completely written to <code>Storage</code>.</p> * * <p>For every instance of this class 2 threads are created, so keep this in * mind when creating instances; this might be a resource hog...</p> * * @author  leo */public class Deleter {        private class DeleteTask implements Runnable {            private Storable storable;        private StorageFactory storageFactory;                DeleteTask(Storable storable, StorageFactory storageFactory) {            this.storable = storable;            this.storageFactory = storageFactory;        }                public void run() {            try {                storageFactory.delete(storable.getStorageName());            } catch (IOException e) {                throw new OzoneInternalException(e);            }        }                public boolean equals(Object obj) {            return false;        }            }        private static final Logger log = Logger.getLogger(Deleter.class.getName());        private AsyncExec asyncExec;    public Deleter(String name) {        asyncExec = new AsyncExec(name, Thread.MIN_PRIORITY, true);    }        /**     * Places a storable into a delete queue. Works like 'Fire and forget'.     */    public void delete(Storable storable, StorageFactory storageFactory) {        if (log.isLoggable(Level.FINER)) log.finer("enqueueing " + storable + " for deletion");        DeleteTask deleteTask = new DeleteTask(storable, storageFactory);        asyncExec.put(deleteTask, deleteTask);    }        public int size() {        return asyncExec.size();    }        public void stopWhenReady() {        asyncExec.stopWhenReady();    }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -