1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 2 // This source code is licensed under both the GPLv2 (found in the 3 // COPYING file in the root directory) and Apache 2.0 License 4 // (found in the LICENSE.Apache file in the root directory). 5 6 package org.rocksdb; 7 8 /** 9 * The type of a thread. 10 */ 11 public enum ThreadType { 12 /** 13 * RocksDB BG thread in high-pri thread pool. 14 */ 15 HIGH_PRIORITY((byte)0x0), 16 17 /** 18 * RocksDB BG thread in low-pri thread pool. 19 */ 20 LOW_PRIORITY((byte)0x1), 21 22 /** 23 * User thread (Non-RocksDB BG thread). 24 */ 25 USER((byte)0x2), 26 27 /** 28 * RocksDB BG thread in bottom-pri thread pool 29 */ 30 BOTTOM_PRIORITY((byte)0x3); 31 32 private final byte value; 33 ThreadType(final byte value)34 ThreadType(final byte value) { 35 this.value = value; 36 } 37 38 /** 39 * Get the internal representation value. 40 * 41 * @return the internal representation value. 42 */ getValue()43 byte getValue() { 44 return value; 45 } 46 47 /** 48 * Get the Thread type from the internal representation value. 49 * 50 * @param value the internal representation value. 51 * 52 * @return the thread type 53 * 54 * @throws IllegalArgumentException if the value does not match a ThreadType 55 */ fromValue(final byte value)56 static ThreadType fromValue(final byte value) 57 throws IllegalArgumentException { 58 for (final ThreadType threadType : ThreadType.values()) { 59 if (threadType.value == value) { 60 return threadType; 61 } 62 } 63 throw new IllegalArgumentException("Unknown value for ThreadType: " + value); 64 } 65 } 66