bonefish+axeld:

* Simplified the notification framework: removed the updater stuff completely;
  it was only there to account for some peculiarities of the node monitor which
  we now solved differently.
* NotificationListener no longer includes a doubly linked list link for convenience;
  it might want to listen to more than just one service.
* NotificationService cannot have an abstract destructor.
* Changed the _user_stop_watching() syscall to mirror the Be API; ie. it's no
  longer possible to just remove some flags separately, just to stop listening
  completely.
* Adapted the node monitor implementation to live in the NodeMonitorService class
  that uses the new notification framework.
* Removed the public kernel node monitor API - it wasn't useful that way since you
  couldn't do a lot with the KMessage in the kernel without using a private API.
  Now you will have to use the (private) notification manager to use the node monitor
  from inside the kernel. At a later point, we might introduce a public API for that,
  too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21780 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-08-01 14:48:44 +00:00
parent 5102d49461
commit edb15b5565
8 changed files with 931 additions and 876 deletions
+18 -54
View File
@@ -22,21 +22,24 @@
#include <Referenceable.h>
#include <util/AutoLock.h>
#include <util/DoublyLinkedList.h>
#include <util/KMessage.h>
#include <util/OpenHashTable.h>
class NotificationService;
class NotificationListener
: public DoublyLinkedListLinkImpl<NotificationListener> {
class NotificationListener {
public:
virtual ~NotificationListener();
virtual void EventOccured(NotificationService& service,
const KMessage* event);
virtual void AllListenersNotified();
virtual void AllListenersNotified(NotificationService& service);
virtual bool operator==(const NotificationListener& other) const;
bool operator!=(const NotificationListener& other) const
{ return !(*this == other); }
};
class UserMessagingMessageSender {
@@ -64,10 +67,10 @@ class UserMessagingListener : public NotificationListener {
virtual void EventOccured(NotificationService& service,
const KMessage* event);
virtual void AllListenersNotified();
virtual void AllListenersNotified(NotificationService& service);
port_id Port() { return fPort; }
int32 Token() { return fToken; }
port_id Port() const { return fPort; }
int32 Token() const { return fToken; }
private:
UserMessagingMessageSender& fSender;
@@ -75,55 +78,16 @@ class UserMessagingListener : public NotificationListener {
int32 fToken;
};
class NotificationListenerUpdater {
public:
enum update_action {
UPDATED,
SKIP,
DELETE,
REMOVE
};
NotificationListenerUpdater(const KMessage* eventSpecifier);
virtual ~NotificationListenerUpdater();
virtual status_t UpdateListener(NotificationListener& listener,
enum update_action& action);
virtual status_t CreateListener(NotificationListener** _listener);
virtual void SetEventSpecifier(const KMessage* eventSpecifier);
const KMessage* EventSpecifier() const { return fEventSpecifier; }
protected:
const KMessage* fEventSpecifier;
};
class UserMessagingListenerUpdater : public NotificationListenerUpdater {
public:
UserMessagingListenerUpdater(const KMessage* eventSpecifier, port_id port,
int32 token);
virtual status_t UpdateListener(NotificationListener& listener,
enum update_action& action);
protected:
virtual status_t UpdateListener(UserMessagingListener& listener,
enum update_action& action) = 0;
port_id fPort;
int32 fToken;
};
class NotificationService : public Referenceable {
public:
virtual ~NotificationService() = 0;
virtual ~NotificationService();
virtual status_t AddListener(const KMessage* eventSpecifier,
NotificationListener& listener) = 0;
virtual status_t RemoveListener(const KMessage* eventSpecifier,
NotificationListener& listener) = 0;
virtual status_t UpdateListener(NotificationListenerUpdater& updater) = 0;
virtual status_t UpdateListener(const KMessage* eventSpecifier,
NotificationListener& listener) = 0;
virtual const char* Name() = 0;
HashTableLink<NotificationService>& Link() { return fLink; }
@@ -148,13 +112,13 @@ class NotificationManager {
status_t AddListener(const char* service,
const KMessage* eventSpecifier, NotificationListener& listener);
status_t RemoveListener(const char* service, uint32 eventMask,
NotificationListener& listener);
status_t RemoveListener(const char* service,
status_t UpdateListener(const char* service,
uint32 eventMask, NotificationListener& listener);
status_t UpdateListener(const char* service,
const KMessage* eventSpecifier, NotificationListener& listener);
status_t UpdateListener(const char* service,
NotificationListenerUpdater& updater);
status_t RemoveListener(const char* service,
const KMessage* eventSpecifier, NotificationListener& listener);
private:
NotificationManager();