LibreOffice Module svl (master) 1
Functions
broadcast.cxx File Reference
#include <svl/broadcast.hxx>
#include <svl/listener.hxx>
#include <svl/hint.hxx>
#include <o3tl/safeint.hxx>
#include <cassert>
#include <algorithm>
Include dependency graph for broadcast.cxx:

Go to the source code of this file.

Functions

static bool isDeletedPtr (SvtListener *p)
 
static void markDeletedPtr (SvtListener *&rp)
 
static void sortListeners (std::vector< SvtListener * > &listeners, size_t firstUnsorted)
 

Function Documentation

◆ isDeletedPtr()

static bool isDeletedPtr ( SvtListener p)
static

Design Notes

This class is extremely heavily used - we can have millions of broadcasters and listeners and we can also have a broadcaster that has a million listeners.

So we do a number of things (*) use a cache-dense listener list (std::vector) because caching effects dominate a lot of operations (*) use a sorted list to speed up find operations (*) only sort the list when we absolutely have to, to speed up sequential add/remove operations (*) defer removing items from the list by (ab)using the last bit of the pointer

Also we have some complications around destruction because (*) we broadcast a message to indicate that we are destructing (*) which can trigger arbitrality complicated behaviour, including (*) adding a removing things from the in-destruction object!

mark deleted entries by toggling the last bit,which is effectively unused, since the struct we point to is at least 16-bit aligned. This allows the binary search to continue working even when we have deleted entries

Definition at line 47 of file broadcast.cxx.

References p.

Referenced by SvtBroadcaster::Add().

◆ markDeletedPtr()

static void markDeletedPtr ( SvtListener *&  rp)
static

Definition at line 55 of file broadcast.cxx.

Referenced by SvtBroadcaster::Remove().

◆ sortListeners()

static void sortListeners ( std::vector< SvtListener * > &  listeners,
size_t  firstUnsorted 
)
static

Definition at line 60 of file broadcast.cxx.

References o3tl::make_unsigned().

Referenced by SvtBroadcaster::Normalize().