Looks good to me, ok for trunk. Thanks.
Jonathan Wakely writes: > Fix synchronization issues in <stop_token>. Replace shared_ptr with > _Stop_state_ref and a reference count embedded in the shared state. > Replace std::mutex with spinlock using one bit of a std::atomic<> that > also tracks whether a stop request has been made and how many > stop_source objects share ownership of the state. > > The synchronization with callbacks being destroyed is based on the > implementation by Lewis Baker and Nico Josuttis. It allows the > callback being destroyed to detect whether it's currently running, and > if so whether on the current thread or a different one. > > Tom, please take a look and give a review. As discussed, the > binary_semaphore is temporary, until we have the real thing.