The ValueCache class is intended to standardize the method for implementing value caching in Cantera, and to reduce the need to introduce additional member variables to store cached variables and the thermodynamic state at which the cached values were computed. The initial usage is to replace the use of the m_tlast variable in IdealGasPhase as an example.
30 lines
372 B
C++
30 lines
372 B
C++
/**
|
|
* @file ValueCache.cpp
|
|
*/
|
|
|
|
#include "cantera/base/ValueCache.h"
|
|
#include "cantera/base/ct_thread.h"
|
|
|
|
namespace
|
|
{
|
|
Cantera::mutex_t id_mutex;
|
|
}
|
|
|
|
namespace Cantera
|
|
{
|
|
|
|
int ValueCache::m_last_id = 0;
|
|
|
|
int ValueCache::getId()
|
|
{
|
|
ScopedLock lock(id_mutex);
|
|
return ++m_last_id;
|
|
}
|
|
|
|
void ValueCache::clear()
|
|
{
|
|
m_scalarCache.clear();
|
|
m_arrayCache.clear();
|
|
}
|
|
|
|
}
|