001    /*
002     * Copyright 2009-2016 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2009-2016 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.util;
022    
023    
024    
025    /**
026     * This enumeration defines a set of thread safety levels that may be used to
027     * indicate whether the associated code is safe to be accessed concurrently
028     * by multiple threads.
029     */
030    public enum ThreadSafetyLevel
031    {
032      /**
033       * The associated code is completely threadsafe and may be accessed
034       * concurrently by any number of threads, subject to the constraints described
035       * in the {@link ThreadSafety} documentation.
036       */
037      COMPLETELY_THREADSAFE,
038    
039    
040    
041      /**
042       * The associated code is mostly threadsafe, but there may be some methods
043       * which are not safe to be invoked when multiple threads are accessing an
044       * instance concurrently.  The class-level documentation for a class including
045       * this thread safety level should include comments indicating which methods
046       * are not threadsafe, and those methods should also be marked with their own
047       * {@code ThreadSafety} annotations using the {@link #METHOD_NOT_THREADSAFE}
048       * level.
049       */
050      MOSTLY_THREADSAFE,
051    
052    
053    
054      /**
055       * The associated code is mostly not threadsafe, but there may be some methods
056       * which are safe to be invoked concurrently by multiple threads.  The
057       * class-level documentation for a class including this thread safety level
058       * should include comments indicating which methods are threadsafe, and those
059       * methods should also be marked with their own {@code ThreadSafety}
060       * annotations using the {@link #METHOD_THREADSAFE} level.
061       */
062      MOSTLY_NOT_THREADSAFE,
063    
064    
065    
066      /**
067       * The associated code is not threadsafe.  Unless otherwise noted, multiple
068       * threads may not attempt to invoke methods on the same instance of objects
069       * of this type without external synchronization.
070       */
071      NOT_THREADSAFE,
072    
073    
074    
075      /**
076       * Methods declared in the associated interface or abstract class must be
077       * threadsafe in classes which implement that interface or extend that
078       * abstract class.  No guarantees will be made about the thread safety of
079       * other methods contained in that class which are not declared in the parent
080       * interface or superclass.
081       */
082      INTERFACE_THREADSAFE,
083    
084    
085    
086      /**
087       * Methods declared in the associated interface or abstract class are not
088       * required to be threadsafe and classes which call them must not rely on the
089       * ability to concurrently invoke those methods on the same object instance
090       * without any external synchronization.
091       */
092      INTERFACE_NOT_THREADSAFE,
093    
094    
095    
096      /**
097       * The associated method may be considered threadsafe and may be invoked
098       * concurrently by multiple threads, subject to the constraints described in
099       * the {@link ThreadSafety} documentation, and in any additional notes
100       * contained in the method-level javadoc.
101       */
102      METHOD_THREADSAFE,
103    
104    
105    
106      /**
107       * The associated method may not be considered threadsafe and should not be
108       * invoked concurrently by multiple threads.
109       */
110      METHOD_NOT_THREADSAFE
111    }