[RCU] Add facility to register cleanup actions to be run when other thread catch up
Summary: In order to avoid the need for synchronization every time a cleanup action is required, it is preferable to register the cleanups and run the cleanup all at once when synchronization is requested.
Test Plan: Added test cases to check cleanups are running as expected.
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien, teamcity, schancel
Differential Revision: https://reviews.bitcoinabc.org/D2317