#include <generic_shared.hpp>
template<typename K, typename T>
class casadi::RevWeakCache< K, T >
Key is stored as a weakref Value is stored as regular ref
Definition at line 343 of file generic_shared.hpp.
|
| void | tocache (const K &key, const T &f, bool needs_lock=true, bool prune=true) |
| |
| void | tocache_if_missing (const K &key, T &f, bool prune=true) |
| |
| bool | incache (const K &key, T &f, bool needs_lock=true) const |
| |
◆ incache()
template<typename K , typename T >
Definition at line 393 of file generic_shared.hpp.
394 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
398 const void* k = key.get();
399 auto it = pre_cache_.find(k);
401 if (it!=pre_cache_.end() && it->second.shared_if_alive(temp)) {
402 auto it2 = cache_.find(k);
◆ tocache()
template<typename K , typename T >
| void casadi::RevWeakCache< K, T >::tocache |
( |
const K & |
key, |
|
|
const T & |
f, |
|
|
bool |
needs_lock = true, |
|
|
bool |
prune = true |
|
) |
| |
|
inline |
Definition at line 345 of file generic_shared.hpp.
347 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
352 const void* k = key.get();
353 auto it = pre_cache_.find(k);
355 if (it == pre_cache_.end()) {
356 pre_cache_.emplace(k, key);
357 cache_.emplace(k, f);
358 }
else if (it->second.get() !=
typename K::base_type(key).weak()->get()) {
362 cache_.find(k)->second = f;
367 for (
auto it = pre_cache_.begin(); it!=pre_cache_.end(); ++it) {
368 if (!it->second.alive()) {
369 const void* dead = it->first;
370 pre_cache_.erase(it);
◆ tocache_if_missing()
template<typename K , typename T >
Definition at line 384 of file generic_shared.hpp.
385 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
387 std::lock_guard<std::mutex> lock(mtx_);
void tocache(const K &key, const T &f, bool needs_lock=true, bool prune=true)
bool incache(const K &key, T &f, bool needs_lock=true) const
The documentation for this class was generated from the following file: