io.daos.dfs.Cleaner Maven / Gradle / Ivy
/*
* (C) Copyright 2018-2021 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
package io.daos.dfs;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Companion cleaner object for opened {@link DaosFile}. When {@link DaosFile} is phantom-reachable,
* this companion cleaner object will be put to a internal {@link ReferenceQueue} which is polled
* repeatedly by a single thread for invoking its {@link #clean()} method.
*
*
* This cleaner is different from {@link sun.misc.Cleaner} that cleaner object cannot be removed once
* created. It means this {@link Cleaner} object's {@link #clean()} is always invoked. If you don't
* want actual clean after this object created, like {@code dfs_release()} for {@link DaosFile}, you can put
* some special logic in {@link Runnable} action.
*
*
* The actual polling and clean is {@link CleanerTask} which is executed in {@link DaosFsClient}.
*
* @see DaosFsClient
*/
public class Cleaner extends PhantomReference