]>
Commit | Line | Data |
---|---|---|
494da23a TL |
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 used to refer to a thread state. | |
10 | * | |
11 | * A state describes lower-level action of a thread | |
12 | * such as reading / writing a file or waiting for a mutex. | |
13 | */ | |
14 | public enum StateType { | |
15 | STATE_UNKNOWN((byte)0x0), | |
16 | STATE_MUTEX_WAIT((byte)0x1); | |
17 | ||
18 | private final byte value; | |
19 | ||
20 | StateType(final byte value) { | |
21 | this.value = value; | |
22 | } | |
23 | ||
24 | /** | |
25 | * Get the internal representation value. | |
26 | * | |
27 | * @return the internal representation value. | |
28 | */ | |
29 | byte getValue() { | |
30 | return value; | |
31 | } | |
32 | ||
33 | /** | |
34 | * Get the State type from the internal representation value. | |
35 | * | |
36 | * @param value the internal representation value. | |
37 | * | |
38 | * @return the state type | |
39 | * | |
40 | * @throws IllegalArgumentException if the value does not match | |
41 | * a StateType | |
42 | */ | |
43 | static StateType fromValue(final byte value) | |
44 | throws IllegalArgumentException { | |
45 | for (final StateType threadType : StateType.values()) { | |
46 | if (threadType.value == value) { | |
47 | return threadType; | |
48 | } | |
49 | } | |
50 | throw new IllegalArgumentException( | |
51 | "Unknown value for StateType: " + value); | |
52 | } | |
53 | } |