I’m exploring the opportunity to “save” threads by moving some of the stuff to the scheduler. I need this so that we can make some room for blocking execution of #18421 and other similar features in future. Later I want to add #18421 to the scheduler too. @laanwj initially suggested to use libevent for #18421, but @thebluematt pointed out that it’s undesirable to add that extra dependency on somewhat limited non-standard libevent functions. Matt also suggested an idea of this PR as an alternative.
I suggest to compare the safety of this approach to status-quo (which seems to be working well). If we’ll have 2 threads for scheduler, the requirement is at most one long blocking task is allowed.
Right now, everything in scheduling is pretty fast. Tor stuff and OpenAddedConnections both seem to be fast too (that’s where I’d use some extra eyes and experience!), so we’re safe, and there’s even room for an extra task. (#18421).
If there are any concerns, note that we can drop either Tor or OpenAddedConnections from the scheduler, and still be fine. Or we can add third thread to the scheduler, and be even with status quo.