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 /cpp/demo/Ice/async/Server.cpp | |
parent | Changed async demo (diff) | |
download | ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.bz2 ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.xz ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.zip |
Changed demo
Diffstat (limited to 'cpp/demo/Ice/async/Server.cpp')
-rw-r--r-- | cpp/demo/Ice/async/Server.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/cpp/demo/Ice/async/Server.cpp b/cpp/demo/Ice/async/Server.cpp index 64a38295ebb..a3d94180741 100644 --- a/cpp/demo/Ice/async/Server.cpp +++ b/cpp/demo/Ice/async/Server.cpp @@ -7,31 +7,63 @@ // // ********************************************************************** -#include <QueueI.h> +#include <HelloI.h> +#include <WorkQueue.h> #include <Ice/Application.h> using namespace std; -class QueueServer : public Ice::Application +class AsyncServer : public Ice::Application { public: virtual int run(int, char*[]); + virtual void interruptCallback(int); + +private: + + WorkQueuePtr _workQueue; }; int main(int argc, char* argv[]) { - QueueServer app; + AsyncServer app; return app.main(argc, argv, "config.server"); } int -QueueServer::run(int argc, char* argv[]) +AsyncServer::run(int argc, char* argv[]) { - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Queue"); - adapter->add(new QueueI, communicator()->stringToIdentity("queue")); + callbackOnInterrupt(); + + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello"); + _workQueue = new WorkQueue(); + adapter->add(new HelloI(_workQueue), communicator()->stringToIdentity("hello")); + + _workQueue->start(); adapter->activate(); + communicator()->waitForShutdown(); return EXIT_SUCCESS; } + +void +AsyncServer::interruptCallback(int) +{ + _workQueue->destroy(); + _workQueue->getThreadControl().join(); + + try + { + communicator()->destroy(); + } + catch(const IceUtil::Exception& ex) + { + cerr << appName() << ": " << ex << endl; + } + catch(...) + { + cerr << appName() << ": unknown exception" << endl; + } +} |