001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     * 
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.performance.pool;
019    
020    /**
021     * Object created by WaiterFactory. Maintains active / valid state.
022     *
023     */
024    public class Waiter {
025        private boolean active = false;
026        private boolean valid = true;
027        long latency = 0;
028        
029        public Waiter(boolean active, boolean valid, long latency) {
030            this.active = active;
031            this.valid = valid;
032            this.latency = latency;
033        }
034    
035        public void doWait() {
036            try {
037                Thread.sleep(latency);
038            } catch (InterruptedException ex) {
039                // ignore
040            }
041        }
042    
043        public boolean isActive() {
044            return active;
045        }
046    
047        public void setActive(boolean active) {
048            this.active = active;
049        }
050    
051        public long getLatency() {
052            return latency;
053        }
054    
055        public void setLatency(long latency) {
056            this.latency = latency;
057        }
058    
059        public boolean isValid() {
060            return valid;
061        }
062    
063        public void setValid(boolean valid) {
064            this.valid = valid;
065        }
066    }