template<typename T, typename TOwner, T(TOwner::*)() const creator>
class CachedItem< T, TOwner, creator >
Wrapper for data that needs to be cached.
The cached data can be accessed via the get() method from multiple threads. The first thread that calls get() will trigger creation of the data item via the creator method, blocking other threads until the item is available in the cache.
- 模板参数
-
T | the type of the data item in the cache. |
TOwner | the class containing the cached item. |
creator | the method of TOwner to call in order to create the data item to be cached. |
在文件 context.cpp 第 91 行定义.
template<typename T , typename TOwner , T(TOwner::*)() const creator>
T& CachedItem< T, TOwner, creator >::get |
( |
const TOwner * |
owner | ) |
const |
|
inline |
Returns a reference to the cached data.
Conceptually this is a const method, i.e. it will always return the same data The first time it is called, the owner will be asked to create the data.
在文件 context.cpp 第 98 行定义.
101 auto creatorFunc = [
this,owner]() {
m_item = (owner->*creator)(); };