1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 module hunt.pool.PooledObjectState;
18 
19 /**
20  * Provides the possible states that a {@link PooledObject} may be in.
21  *
22  */
23 public enum PooledObjectState {
24     /**
25      * In the queue, not in use.
26      */
27     IDLE,
28 
29     /**
30      * In use.
31      */
32     ALLOCATED,
33 
34     /**
35      * In the queue, currently being tested for possible eviction.
36      */
37     EVICTION,
38 
39     /**
40      * Not in the queue, currently being tested for possible eviction. An
41      * attempt to borrow the object was made while being tested which removed it
42      * from the queue. It should be returned to the head of the queue once
43      * eviction testing completes.
44      * TODO: Consider allocating object and ignoring the result of the eviction
45      *       test.
46      */
47     EVICTION_RETURN_TO_HEAD,
48 
49     /**
50      * In the queue, currently being validated.
51      */
52     VALIDATION,
53 
54     /**
55      * Not in queue, currently being validated. The object was borrowed while
56      * being validated and since testOnBorrow was configured, it was removed
57      * from the queue and pre-allocated. It should be allocated once validation
58      * completes.
59      */
60     VALIDATION_PREALLOCATED,
61 
62     /**
63      * Not in queue, currently being validated. An attempt to borrow the object
64      * was made while previously being tested for eviction which removed it from
65      * the queue. It should be returned to the head of the queue once validation
66      * completes.
67      */
68     VALIDATION_RETURN_TO_HEAD,
69 
70     /**
71      * Failed maintenance (e.g. eviction test or validation) and will be / has
72      * been destroyed
73      */
74     INVALID,
75 
76     /**
77      * Deemed abandoned, to be invalidated.
78      */
79     ABANDONED,
80 
81     /**
82      * Returning to the pool.
83      */
84     RETURNING
85 }