On Feb 7, 2020, at 13:26, Han-Wen Nienhuys <hanw...@gmail.com> wrote: > > To do https://codereview.appspot.com/561390043/ properly, I have to expand > the heap when GC notifies us that a collection took place. Unfortunately, > libgc notifications are done with the garbage collector lock held. So I'll > need schedule a call to GC_expand_heap on a different thread. > > Would you know what is the best way to do this in C++ nowadays?
I wish I could give you a ready-made solution, but the multi-threaded systems I've worked on in the past decade were designed so that most of the development team could concentrate on single-threaded problems. Only a couple of people needed to understand the load-balancing/scheduling code, and I was not one of them. I can point to the C++11 thread support and atomic operations libraries: https://en.cppreference.com/w/cpp/thread https://en.cppreference.com/w/cpp/atomic Anything else I might say would be speculative. I'd probably start with the std::thread class. — Dan