summaryrefslogtreecommitdiff
path: root/cpp/src/IceStorm/Subscriber.h
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2006-11-10 10:01:41 +0000
committerMatthew Newhook <matthew@zeroc.com>2006-11-10 10:01:41 +0000
commitadcbd76c9a3e4f4e446d216d0b5fb1ebd8ab53e0 (patch)
tree57fceade2f93e7dc2075eeb199b7fe7406e3e663 /cpp/src/IceStorm/Subscriber.h
parentAdded ImplicitContextF.ice (diff)
downloadice-adcbd76c9a3e4f4e446d216d0b5fb1ebd8ab53e0.tar.bz2
ice-adcbd76c9a3e4f4e446d216d0b5fb1ebd8ab53e0.tar.xz
ice-adcbd76c9a3e4f4e446d216d0b5fb1ebd8ab53e0.zip
rename source file.
Diffstat (limited to 'cpp/src/IceStorm/Subscriber.h')
-rw-r--r--cpp/src/IceStorm/Subscriber.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h
new file mode 100644
index 00000000000..ac1fb7bbb19
--- /dev/null
+++ b/cpp/src/IceStorm/Subscriber.h
@@ -0,0 +1,107 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2006 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 SUBSCRIBERS_H
+#define SUBSCRIBERS_H
+
+#include <IceStorm/IceStormInternal.h> // F
+#include <IceStorm/Event.h>
+
+namespace IceStorm
+{
+
+class Instance;
+typedef IceUtil::Handle<Instance> InstancePtr;
+
+class Subscriber;
+typedef IceUtil::Handle<Subscriber> SubscriberPtr;
+
+class Subscriber : public IceUtil::Shared
+{
+public:
+
+ static SubscriberPtr create(const InstancePtr&, const Ice::ObjectPrx&, const IceStorm::QoS&);
+ static SubscriberPtr create(const InstancePtr&, const TopicLinkPrx&, int);
+
+ ~Subscriber();
+
+ void reachable();
+ Ice::ObjectPrx proxy() const;
+ Ice::Identity id() const;
+ bool persistent() const;
+
+ enum QueueState
+ {
+ QueueStateError,
+ QueueStateFlush,
+ QueueStateNoFlush
+ };
+ virtual QueueState queue(bool, const std::vector<EventPtr>&);
+ //
+ // Return true if flush() must be called again, false otherwise.
+ //
+ virtual bool flush() = 0;
+ virtual void destroy();
+
+ //
+ // These methods must only be called by the SubscriberPool they
+ // are not internally mutex protected.
+ //
+ void flushTime(const IceUtil::Time&);
+ IceUtil::Time pollMaxFlushTime(const IceUtil::Time&);
+
+ void setError(const Ice::Exception&);
+ void setUnreachable(const Ice::Exception&);
+
+protected:
+
+ Subscriber(const InstancePtr&, const Ice::ObjectPrx&, bool, const Ice::Identity&);
+
+ // Immutable
+ const InstancePtr _instance;
+ const Ice::Identity _id;
+ const bool _persistent;
+ const Ice::ObjectPrx _proxy;
+
+ IceUtil::Mutex _mutex;
+
+ enum State
+ {
+ //
+ // The Subscriber is active.
+ //
+ StateActive,
+ //
+ // The Subscriber encountered an error during event
+ // transmission.
+ //
+ StateError,
+ //
+ // The Subscriber is no longer reachable.
+ //
+ StateUnreachable
+ };
+ State _state;
+
+ bool _busy;
+ EventSeq _events;
+
+ //
+ // Not protected by _mutex. These members are protected by the
+ // SubscriberPool mutex.
+ //
+ bool _resetMax;
+ IceUtil::Time _maxSend;
+};
+
+bool operator==(const IceStorm::SubscriberPtr&, const Ice::Identity&);
+
+}
+
+#endif // SUBSCRIBERS_H