On Monday, 30 December 2019 15:31:14 -03 Narolewski Jakub wrote: > I did not notice if unregisterTimer() and registerTimer() are also called > so often but their non-destructive switching could also come in handy. > Do you think that changing current QSocketNotifier::setEnabled( bool ) > behaviour to actually enable / disable notifiers is a good idea?
I don't see why not. In fact, I'm positive it is a good idea. In all implementations, there's a cost associated with registering a notifier. So the worst case scenario is that in an implementation it's impossible to disable, forcing us to fall back to deregistering with the low-level implementation. That's exactly what we do today, so it's no worse. We do need some bookkeeing so we can re-register on setSocketDescriptorEnabled(), but I guess that it's the bookkeeping that's already there. The drawback is of the increased memory consumption by QSocketNotifiers that stay mostly disabled. That is the case for the write notifiers for all sockets, which are only enabled when they have something to write. I think that's an acceptable trade-off. > I don't know much about Qt at this level or how much of current code > depends on them actually registering and deregistering. > > Also, does QSocketNotifier 'know' when it is supposed to release underlying > socket? Today, on setEnabled(false) or destruction. If we implement the new feature, only on destruction. > Could registering and deregistering be moved entirely to its constructor > and destructor? That's what I hope. > I don't know how QAbstractEventDispatcher interops with QTimer, I will try > to research it a bit more. It's basically the same. The one thing to look after is that QAbstractSocket has a shortcut to skip some of the signal-slot mechanisms of QSocketNotifier and be notified immediately by way of a virtual. So there's a second place to deal with registering/unregistering, aside from QSocketNotifier. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel System Software Products _______________________________________________ Interest mailing list [email protected] https://lists.qt-project.org/listinfo/interest
