diff options
Diffstat (limited to 'cs/demo/Ice/async')
-rw-r--r-- | cs/demo/Ice/async/Client.cs | 54 | ||||
-rw-r--r-- | cs/demo/Ice/async/HelloI.cs | 6 | ||||
-rw-r--r-- | cs/demo/Ice/async/Server.cs | 40 | ||||
-rw-r--r-- | cs/demo/Ice/async/WorkQueue.cs | 128 |
4 files changed, 114 insertions, 114 deletions
diff --git a/cs/demo/Ice/async/Client.cs b/cs/demo/Ice/async/Client.cs index b22b2c98113..ed74f2043da 100644 --- a/cs/demo/Ice/async/Client.cs +++ b/cs/demo/Ice/async/Client.cs @@ -15,20 +15,20 @@ public class Client : Ice.Application public class AMI_Hello_sayHelloI : AMI_Hello_sayHello { public override void ice_response() - { - } + { + } - public override void ice_exception(Ice.Exception ex) - { - if(ex is RequestCanceledException) - { - Console.Error.WriteLine("Request canceled"); - } - else - { - Console.Error.WriteLine(ex); - } - } + public override void ice_exception(Ice.Exception ex) + { + if(ex is RequestCanceledException) + { + Console.Error.WriteLine("Request canceled"); + } + else + { + Console.Error.WriteLine(ex); + } + } } private static void menu() @@ -59,31 +59,31 @@ public class Client : Ice.Application try { Console.Out.Write("==> "); - Console.Out.Flush(); - line = Console.In.ReadLine(); + Console.Out.Flush(); + line = Console.In.ReadLine(); if(line == null) { break; } if(line.Equals("i")) - { - hello.sayHello(0); - } + { + hello.sayHello(0); + } else if(line.Equals("d")) { hello.sayHello_async(new AMI_Hello_sayHelloI(), 5000); } else if(line.Equals("s")) - { - hello.shutdown(); - } + { + hello.shutdown(); + } else if(line.Equals("x")) { // Nothing to do } else if(line.Equals("?")) { - menu(); + menu(); } else { @@ -93,7 +93,7 @@ public class Client : Ice.Application } catch(Ice.Exception ex) { - Console.Error.WriteLine(ex); + Console.Error.WriteLine(ex); } } while(!line.Equals("x")); @@ -105,9 +105,9 @@ public class Client : Ice.Application { Client app = new Client(); int status = app.main(args, "config.client"); - if(status != 0) - { - System.Environment.Exit(status); - } + if(status != 0) + { + System.Environment.Exit(status); + } } } diff --git a/cs/demo/Ice/async/HelloI.cs b/cs/demo/Ice/async/HelloI.cs index 10ab48b53bc..4d7f51facc2 100644 --- a/cs/demo/Ice/async/HelloI.cs +++ b/cs/demo/Ice/async/HelloI.cs @@ -22,7 +22,7 @@ public class HelloI : HelloDisp_ if(delay == 0) { Console.Out.WriteLine("Hello World!"); - cb.ice_response(); + cb.ice_response(); } else { @@ -33,9 +33,9 @@ public class HelloI : HelloDisp_ public override void shutdown(Ice.Current current) { _workQueue.destroy(); - _workQueue.Join(); + _workQueue.Join(); - current.adapter.getCommunicator().shutdown(); + current.adapter.getCommunicator().shutdown(); } private WorkQueue _workQueue; diff --git a/cs/demo/Ice/async/Server.cs b/cs/demo/Ice/async/Server.cs index 96eec8d302d..e0363683017 100644 --- a/cs/demo/Ice/async/Server.cs +++ b/cs/demo/Ice/async/Server.cs @@ -14,10 +14,10 @@ public class Server : Ice.Application callbackOnInterrupt(); Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - _workQueue = new WorkQueue(); + _workQueue = new WorkQueue(); adapter.add(new HelloI(_workQueue), communicator().stringToIdentity("hello")); - _workQueue.Start(); + _workQueue.Start(); adapter.activate(); communicator().waitForShutdown(); @@ -27,30 +27,30 @@ public class Server : Ice.Application public override void interruptCallback(int sig) { _workQueue.destroy(); - _workQueue.Join(); - - try - { - communicator().destroy(); - } - catch(Ice.Exception ex) - { - System.Console.Error.WriteLine(appName() + ": " + ex); - } - catch(System.Exception ex) - { - System.Console.Error.WriteLine(appName() + ": unknown exception: " + ex); - } + _workQueue.Join(); + + try + { + communicator().destroy(); + } + catch(Ice.Exception ex) + { + System.Console.Error.WriteLine(appName() + ": " + ex); + } + catch(System.Exception ex) + { + System.Console.Error.WriteLine(appName() + ": unknown exception: " + ex); + } } public static void Main(string[] args) { Server app = new Server(); int status = app.main(args, "config.server"); - if(status != 0) - { - System.Environment.Exit(status); - } + if(status != 0) + { + System.Environment.Exit(status); + } } private WorkQueue _workQueue; diff --git a/cs/demo/Ice/async/WorkQueue.cs b/cs/demo/Ice/async/WorkQueue.cs index 186ed6349a2..e5f0e5ba306 100644 --- a/cs/demo/Ice/async/WorkQueue.cs +++ b/cs/demo/Ice/async/WorkQueue.cs @@ -17,7 +17,7 @@ public class WorkQueue private class CallbackEntry { public AMD_Hello_sayHello cb; - public int delay; + public int delay; } public void Join() @@ -28,89 +28,89 @@ public class WorkQueue public void Start() { thread_ = new Thread(new ThreadStart(Run)); - thread_.Start(); + thread_.Start(); } public void Run() { lock(this) - { - while(!_done) - { - if(_callbacks.Count == 0) - { - Monitor.Wait(this); - } + { + while(!_done) + { + if(_callbacks.Count == 0) + { + Monitor.Wait(this); + } - if(_callbacks.Count != 0) - { - // - // Get next work item. - // - CallbackEntry entry = (CallbackEntry)_callbacks[0]; + if(_callbacks.Count != 0) + { + // + // Get next work item. + // + CallbackEntry entry = (CallbackEntry)_callbacks[0]; - // - // Wait for the amount of time indicated in delay to - // emulate a process that takes a significant period of - // time to complete. - // - Monitor.Wait(this, entry.delay); + // + // Wait for the amount of time indicated in delay to + // emulate a process that takes a significant period of + // time to complete. + // + Monitor.Wait(this, entry.delay); - if(!_done) - { - // - // Print greeting and send response. - // - _callbacks.RemoveAt(0); - Console.Out.WriteLine("Belated Hello World!"); - entry.cb.ice_response(); - } - } - } + if(!_done) + { + // + // Print greeting and send response. + // + _callbacks.RemoveAt(0); + Console.Out.WriteLine("Belated Hello World!"); + entry.cb.ice_response(); + } + } + } - foreach(CallbackEntry e in _callbacks) - { - e.cb.ice_exception(new RequestCanceledException()); - } - } + foreach(CallbackEntry e in _callbacks) + { + e.cb.ice_exception(new RequestCanceledException()); + } + } } public void Add(AMD_Hello_sayHello cb, int delay) { lock(this) - { - if(!_done) - { - // - // Add the work item. - // - CallbackEntry entry = new CallbackEntry(); - entry.cb = cb; - entry.delay = delay; + { + if(!_done) + { + // + // Add the work item. + // + CallbackEntry entry = new CallbackEntry(); + entry.cb = cb; + entry.delay = delay; - if(_callbacks.Count == 0) - { - Monitor.Pulse(this); - } - _callbacks.Add(entry); - } - else - { - // - // Destroyed, throw exception. - // - cb.ice_exception(new RequestCanceledException()); - } - } + if(_callbacks.Count == 0) + { + Monitor.Pulse(this); + } + _callbacks.Add(entry); + } + else + { + // + // Destroyed, throw exception. + // + cb.ice_exception(new RequestCanceledException()); + } + } } public void destroy() { lock(this) - { - _done = true; - Monitor.Pulse(this); - } + { + _done = true; + Monitor.Pulse(this); + } } private ArrayList _callbacks = new ArrayList(); |