diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
commit | e124e693704faa56ecf32ce2a243d0c3fa3a5e6e (patch) | |
tree | 071dcaa6edc458f9371289976a4537880e5bb005 /java/demo/Ice/async/QueueI.java | |
parent | Changed async demo (diff) | |
download | ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.bz2 ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.xz ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.zip |
Changed demo
Diffstat (limited to 'java/demo/Ice/async/QueueI.java')
-rw-r--r-- | java/demo/Ice/async/QueueI.java | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/java/demo/Ice/async/QueueI.java b/java/demo/Ice/async/QueueI.java deleted file mode 100644 index 3ad48eca475..00000000000 --- a/java/demo/Ice/async/QueueI.java +++ /dev/null @@ -1,109 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2007 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. -// -// ********************************************************************** - -import Demo.*; - -public class QueueI extends _QueueDisp -{ - synchronized public void - get_async(AMD_Queue_get cb, String id, Ice.Current current) - { - // - // If there is already a message in the message queue, send the - // response immediately. Otherwise add the callback to the - // request queue. - // - if(_messageQueue.size() != 0) - { - try - { - cb.ice_response((String)_messageQueue.getFirst()); - _messageQueue.removeFirst(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - else - { - Request request = new Request(); - request.id = id; - request.cb = cb; - _requestQueue.add(request); - } - } - - synchronized public void - add(String message, Ice.Current current) - { - // - // If there is an outstanding request in the request queue, - // send a response. Otherwise add the message to the message - // queue. - // - if(_requestQueue.size() != 0) - { - try - { - Request request = (Request)_requestQueue.removeFirst(); - request.cb.ice_response(message); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - else - { - _messageQueue.add(message); - } - } - - synchronized public void - cancel_async(AMD_Queue_cancel cb, String[] ids, Ice.Current current) - { - // - // We send immediate response so that later call to ice_exception - // on queued requests will not cause deadlocks. - // - cb.ice_response(); - - for(int i = 0; i < ids.length; ++i) - { - java.util.Iterator p = _requestQueue.iterator(); - while(p.hasNext()) - { - Request request = (Request)p.next(); - if(request.id.equals(ids[i])) - { - try - { - request.cb.ice_exception(new RequestCanceledException()); - } - catch(Ice.LocalException ex) - { - // Ignore - } - p.remove(); - break; - } - } - } - } - - class Request - { - String id; - AMD_Queue_get cb; - } - - private java.util.LinkedList _messageQueue = new java.util.LinkedList(); - private java.util.LinkedList _requestQueue = new java.util.LinkedList(); -} |