18#ifndef CIRCUIT_CACHE_CPP_H
19#define CIRCUIT_CACHE_CPP_H
27#include <boost/multi_index_container.hpp>
28#include <boost/multi_index/hashed_index.hpp>
29#include <boost/multi_index/member.hpp>
30#include <boost/multi_index/sequenced_index.hpp>
32using namespace boost::multi_index;
54 inline unsigned size()
const {
74typedef multi_index_container<
78 hashed_unique<member<CircuitCacheInfos, pg_uuid_t, &CircuitCacheInfos::token> >
115std::optional<CircuitCacheInfos>
get(
pg_uuid_t token)
const;
Bounded LRU cache mapping gate UUIDs to their CircuitCacheInfos.
CircuitCache()
Construct an empty cache.
multi_index_container< CircuitCacheInfos, indexed_by< sequenced<>, hashed_unique< member< CircuitCacheInfos, pg_uuid_t, &CircuitCacheInfos::token > > > > item_list
Boost multi-index container type for cache entries.
item_list il
The container holding cached entries.
item_list::iterator iterator
Iterator type for iterating over cache entries in FIFO order.
unsigned current_size
Current total byte usage of cached entries.
CircuitCacheInfos item_type
The value type stored in the cache.
iterator end()
Past-the-end iterator for the cache.
iterator begin()
Iterator to the first cached entry (oldest).
bool insert(const CircuitCacheInfos &infos)
Insert a new gate into the cache, evicting the oldest if necessary.
std::optional< CircuitCacheInfos > get(pg_uuid_t token) const
Look up a gate by UUID.
gate_type
Possible gate type in the provenance circuit.
C++ utility functions for UUID manipulation.
All information stored for a single gate in the circuit cache.
std::vector< pg_uuid_t > children
Ordered list of child gate UUIDs.
unsigned size() const
Estimated memory footprint of this entry in bytes.
gate_type type
Kind of gate (input, plus, times, …)
pg_uuid_t token
UUID identifying this gate.