We split each of the InitByteNoThreads, InitByteGlobalMutex, and
InitByteFutex classes into 2 different classes.
The three new classes NoThreadsGuard, GlobalMutexGuard, and FutexGuard
replace the old classes, and the old classes now focus only on
providing functions for managing reads/writes to the init byte. That is,
the definitions of acquire/release/abort_init_byte, remain in the old
classes, but nothing else.
The new classes are then responsible for everything else: dividing up
the raw guard object, providing cxa_guard_acquire/release/abort (by
inheriting from GuardObject), etc.
This is the 3rd of 6 changes to overhaul cxa_guard.
See D108343 for what the final result will be and more details on why
cxa_guard is getting overhauled.
Depends on D110088
I was looking at this patch and I found that using CRTP for this was adding a lot of complexity. It it possible that using a free function (template) for implementing cxa_guard_acquire, cxa_guard_release and cxa_guard_abort would greatly simplify things? Imagine:
Then, for example NoThreadsGuard would become:
At that point we might want to simplify the whole thing and simply call InitByteNoThreads NoThreadsGuard directly.