tlds
Transactional Operations for Linked Data Structures
|
Static Public Member Functions | |
static void | init () |
Template Metaprogramming trick for initializing all STM algorithms.
This is either a very gross trick, or a very cool one. We have ALG_MAX algorithms, and they all need to be initialized. Each has a unique identifying integer, and each is initialized by calling an instantiation of initTM<> with that integer.
Rather than call each function through a line of code, we use a tail-recursive template: When we call MetaInitializer<0>.init(), it will recursively call itself for every X, where 0 <= X < ALG_MAX. Since MetaInitializer<X>::init() calls initTM<X> before recursing, this instantiates and calls the appropriate initTM function. Thus we correctly call all initialization functions.
Furthermore, since the code is tail-recursive, at -O3 g++ will inline all the initTM calls right into the sys_init function. While the code is not performance critical, it's still nice to avoid the overhead.
|
inlinestatic |