diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-04-19 07:22:26 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-04-19 07:22:26 +0000 |
commit | 21d4f05364a1bd09eabc075a3bffdbae4d0b92b5 (patch) | |
tree | 5d9664798d26581ddc3e47ed6224ee877dca2e90 /cpp/demo/Ice/session/ReapThread.h | |
parent | Added missing lock. (diff) | |
download | ice-21d4f05364a1bd09eabc075a3bffdbae4d0b92b5.tar.bz2 ice-21d4f05364a1bd09eabc075a3bffdbae4d0b92b5.tar.xz ice-21d4f05364a1bd09eabc075a3bffdbae4d0b92b5.zip |
addressed few more concerns.
Diffstat (limited to 'cpp/demo/Ice/session/ReapThread.h')
-rwxr-xr-x | cpp/demo/Ice/session/ReapThread.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cpp/demo/Ice/session/ReapThread.h b/cpp/demo/Ice/session/ReapThread.h new file mode 100755 index 00000000000..7667e8b16dd --- /dev/null +++ b/cpp/demo/Ice/session/ReapThread.h @@ -0,0 +1,59 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 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. +// +// ********************************************************************** + +#ifndef REAP_THREAD_H +#define REAP_THREAD_H + +#include <IceUtil/Thread.h> +#include <IceUtil/StaticMutex.h> +#include <SessionI.h> + +class ReapThread; +typedef IceUtil::Handle<ReapThread> ReapThreadPtr; +class ReapThread : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> +{ +public: + + static ReapThreadPtr& instance(); + + virtual ~ReapThread(); + + virtual void run(); + + // XXX Rename to destroy(). + // + // I named it terminate because destroy() methods in Java result + // in a deprecation warning. If you want to use destroy() in Java + // then I would have to use a runnable which means the demo isn't + // the same code. Given the difference is a method name, I didn't + // think it was worth the cost of different code. + // + void terminate(); + + // XXX: The alternative here is to make timestamp() a slice + // method. However, this means that we're adding methods to the + // slice interface which is only required for the reaping thread, + // and it obviously couldn't return an IceUtil::Time but instead + // some other representation... + // + void add(const ::Demo::SessionPrx&, const SessionIPtr&); + +private: + + ReapThread(); + + const IceUtil::Time _timeout; + bool _terminated; + std::map< ::Demo::SessionPrx, SessionIPtr> _sessions; + + static ReapThreadPtr _instance; + static IceUtil::StaticMutex _instanceMutex; +}; + +#endif |