Implement RCU synchronization mechanism
Summary:
This is a userspace implementation of the RCU synchronization primitives.
It is achieved by using a structure per thread in thread local storage. The structures are put together in a linked list that can be traversed lock free by the synchronize operation. The structures are removed from the linkedlist when a thread is shut down.
The synchronization is based on a global revision variable which works in a way similar to source control. The synchronize operation increment the revision and wait for each thread is eithernotholding the lock or have advanced past the revision numer to consider a given state synchronized.
Each thread keep track of the revision it has reached when acquiring the RCULock in its threadlocal datastructure. When the lock is released, a special value is put in the local state indicating that the thread is not currently holding the lock.
Test Plan: Added unit test to cover the whole mechanism and check each intermediate step. Ran the test with COUNT = 4000000 .
Reviewers: #bitcoin_abc, Fabien, jasonbcox
Reviewed By: #bitcoin_abc, Fabien, jasonbcox
Subscribers: jasonbcox, Fabien, teamcity, schancel
Differential Revision: https://reviews.bitcoinabc.org/D2245