01: package org.jacorb.notification.queue;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1999-2004 Gerald Brose
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Library General Public License for more details.
17: *
18: * You should have received a copy of the GNU Library General Public
19: * License along with this library; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: import org.jacorb.notification.interfaces.Message;
25:
26: /**
27: * Note that most of the methods are not thread-safe. this causes no problem as
28: * the methods are not intended to be directly called by clients. instead the superclass
29: * implements the interface EventQueue and invokes the methods thereby synchronizing access.
30: *
31: * @author Alphonse Bendt
32: * @version $Id: BoundedDeadlineEventQueue.java,v 1.9 2006/02/25 15:28:40 alphonse.bendt Exp $
33: */
34:
35: public class BoundedDeadlineEventQueue extends AbstractBoundedEventHeap {
36: public BoundedDeadlineEventQueue(int maxSize,
37: EventQueueOverflowStrategy overflowStrategy) {
38: super (maxSize, overflowStrategy, new Object(),
39: QueueUtil.ASCENDING_TIMEOUT_COMPARATOR);
40: }
41:
42: ////////////////////////////////////////
43:
44: public String getOrderPolicyName() {
45: return "DeadlineOrder";
46: }
47:
48: protected Message getOldestElement() {
49: return removeFirstElement(QueueUtil.ASCENDING_INSERT_ORDER_COMPARATOR);
50: }
51:
52: protected Message getYoungestElement() {
53: return removeFirstElement(QueueUtil.DESCENDING_INSERT_ORDER_COMPARATOR);
54: }
55:
56: protected Message getEarliestTimeout() {
57: return getNextHeapElement();
58: }
59:
60: protected Message getLeastPriority() {
61: return removeFirstElement(QueueUtil.ASCENDING_PRIORITY_COMPARATOR);
62: }
63: }
|