diff options
Diffstat (limited to 'java/src/IceInternal/RetryQueue.java')
-rw-r--r-- | java/src/IceInternal/RetryQueue.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/java/src/IceInternal/RetryQueue.java b/java/src/IceInternal/RetryQueue.java new file mode 100644 index 00000000000..0e0065ab2df --- /dev/null +++ b/java/src/IceInternal/RetryQueue.java @@ -0,0 +1,49 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public class RetryQueue +{ + RetryQueue(Instance instance) + { + _instance = instance; + } + + synchronized public void + add(OutgoingAsync outAsync, int interval) + { + RetryTask task = new RetryTask(this, outAsync); + _instance.timer().schedule(task, interval); + _requests.add(task); + } + + synchronized public void + destroy() + { + java.util.Iterator<RetryTask> p = _requests.iterator(); + while(p.hasNext()) + { + RetryTask task = p.next(); + _instance.timer().cancel(task); + task.destroy(); + } + _requests.clear(); + } + + synchronized boolean + remove(RetryTask task) + { + return _requests.remove(task); + } + + final private Instance _instance; + final private java.util.HashSet<RetryTask> _requests = new java.util.HashSet<RetryTask>(); +}; + |