summaryrefslogtreecommitdiff
path: root/include/svl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2013-12-21 01:41:18 +0100
committerJan Holesovsky <kendy@collabora.com>2013-12-21 02:07:32 +0100
commitefb30219a1113ee08bf26160a08b4f721a514fdf (patch)
treeb17d35622295131493d6fe6aa744fc4dfb498650 /include/svl
parent0d5d01a4d4d7dbdfaea4cf2a44094b58f09d1baa (diff)
Speedup destruction of sheets with too many listeners & broadcasters.
Listeners and broadcasters are M:N relationship. If you want to destruct them, you easily end up in O(M*N) situation; where for every listener, you iterate all broadcasters, to remove that one listener. To avoid that, announce to the broadcasters that they are going to die, and the listeners do not have to bother with removing themselves from the broadcaster. The broadcaster will not broadcast anything after the PrepareForDesctruction() call anyway. Change-Id: I68d78b23e73bcbb944de9139448b2c20dfa14f62
Diffstat (limited to 'include/svl')
-rw-r--r--include/svl/broadcast.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/svl/broadcast.hxx b/include/svl/broadcast.hxx
index 6a6bc03c6fd6..d122e02594c6 100644
--- a/include/svl/broadcast.hxx
+++ b/include/svl/broadcast.hxx
@@ -60,8 +60,21 @@ public:
bool HasListeners() const;
+ /**
+ * Listeners and broadcasters are M:N relationship. If you want to
+ * destruct them, you easily end up in O(M*N) situation; where for every
+ * listener, you iterate all broadcasters, to remove that one listener.
+ *
+ * To avoid that, use this call to announce to the broadcaster it is going
+ * to die, and the listeners do not have to bother with removing
+ * themselves from the broadcaster - the broadcaster will not broadcast
+ * anything after the PrepareForDesctruction() call anyway.
+ */
+ void PrepareForDestruction() { mbAboutToDie = true; }
+
private:
ListenersType maListeners;
+ bool mbAboutToDie:1;
bool mbDisposing:1;
bool mbNormalized:1;
};