KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > util > timeout > TimeoutPriorityQueue


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.util.timeout;
23
24 /**
25  * TimeoutPriorityQueue.
26  *
27  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
28  * @version $Revision: 1958 $
29  */

30 public interface TimeoutPriorityQueue
31 {
32    /**
33     * Add a timeout to the queue
34     *
35     * @param time the time of the timeout
36     * @param target the timeout target
37     * @return timeout when it was added to the queue, false otherwise
38     */

39    TimeoutExt offer(long time, TimeoutTarget target);
40    
41    /**
42     * Take a timeout when it times out
43     *
44     * @return the top the queue or null if the queue is cancelled
45     */

46    TimeoutExt take();
47    
48    /**
49     * Retrieves and removes the top of the queue if it times out
50     * or null if there is no such element
51     *
52     * @return the top the queue or null if the queue is empty
53     */

54    TimeoutExt poll();
55    
56    /**
57     * Retrieves and removes the top of the queue if it times out
58     * or null if there is no such element
59     *
60     * @param wait how to long to wait in milliseconds
61     * if the queue is empty
62     * @return the top of the queue or null if the queue is empty
63     */

64    TimeoutExt poll(long wait);
65    
66    /**
67     * Retrieves but does not remove the top of the queue
68     * or null if there is no such element
69     *
70     * @return the top of the queue or null if the queue is empty
71     */

72    TimeoutExt peek();
73    
74    /**
75     * Removes the passed timeout from the queue
76     *
77     * @return true when the timeout was removed
78     */

79    boolean remove(TimeoutExt timeout);
80    
81    /**
82     * Clears the queue
83     */

84    void clear();
85    
86    /**
87     * Cancels the queue
88     */

89    void cancel();
90    
91    /**
92     * The size of the queue
93     */

94    int size();
95 }
96
Popular Tags