Cantera 2.6.0

ValueCache.cpp
Go to the documentation of this file.
1/**
2 * @file ValueCache.cpp
3 */
4
5// This file is part of Cantera. See License.txt in the top-level directory or
6// at https://cantera.org/license.txt for license and copyright information.
7
8#include "cantera/base/ValueCache.h"
9#include <mutex>
10
11 namespace
12{
13std::mutex id_mutex;
14}
15
16 namespace Cantera
17{
18
19 int ValueCache::m_last_id = 0;
20
21 int ValueCache::getId()
22{
23 std::unique_lock<std::mutex> lock(id_mutex);
24 return ++m_last_id;
25}
26
27 void ValueCache::clear()
28{
29 m_scalarCache.clear();
30 m_arrayCache.clear();
31}
32
33}
ValueCache.h
Cantera::ValueCache::getId
int getId()
Get a unique id for a cached value.
Definition: ValueCache.cpp:21
Cantera::ValueCache::m_scalarCache
std::map< int, CachedValue< double > > m_scalarCache
Cached scalar values.
Definition: ValueCache.h:183
Cantera::ValueCache::m_arrayCache
std::map< int, CachedValue< vector_fp > > m_arrayCache
Cached array values.
Definition: ValueCache.h:186
Cantera::ValueCache::clear
void clear()
Clear all cached values.
Definition: ValueCache.cpp:27
Cantera::ValueCache::m_last_id
static int m_last_id
The last assigned id. Automatically incremented by the getId() method.
Definition: ValueCache.h:189
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557