tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
stm::MetaInitializer< I > Struct Template Reference
Collaboration diagram for stm::MetaInitializer< I >:

Static Public Member Functions

static void init ()
 

Detailed Description

template<int I = 0>
struct stm::MetaInitializer< I >

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.

Member Function Documentation

template<int I = 0>
static void stm::MetaInitializer< I >::init ( )
inlinestatic

Here is the caller graph for this function:


The documentation for this struct was generated from the following file: