Pool of runtime instances - per state. Incapsulates modules cache.
More...
#include <runtime_instances_pool.hpp>
Pool of runtime instances - per state. Incapsulates modules cache.
Definition at line 86 of file runtime_instances_pool.hpp.
std::optional< std::shared_ptr< Module > > kagome::runtime::RuntimeInstancesPool::getModule |
( |
const RootHash & |
state | ) |
|
Get the module for state from internal cache.
- Parameters
-
state | - the state containing the module's code. |
- Returns
- Module if any, nullopt otherwise
Definition at line 98 of file runtime_instances_pool.cpp.
void kagome::runtime::RuntimeInstancesPool::putModule |
( |
const RootHash & |
state, |
|
|
std::shared_ptr< Module > |
module |
|
) |
| |
Puts new module into internal cache.
- Parameters
-
state | - runtime block, by its root hash |
module | - new module pointer |
Definition at line 104 of file runtime_instances_pool.cpp.
void kagome::runtime::RuntimeInstancesPool::release |
( |
const RootHash & |
state, |
|
|
std::shared_ptr< ModuleInstance > && |
instance |
|
) |
| |
Releases the module instance (returns it to the pool)
- Parameters
-
state | - the merkle trie root of the state containing the runtime module code we are releasing an instance of. |
instance | - instance to be released. |
Definition at line 89 of file runtime_instances_pool.cpp.
outcome::result< std::shared_ptr< ModuleInstance > > kagome::runtime::RuntimeInstancesPool::tryAcquire |
( |
const RootHash & |
state | ) |
|
Instantiate new or reuse existing ModuleInstance for the provided state.
- Parameters
-
state | - the merkle trie root of the state containing the code of the runtime module we are acquiring an instance of. |
- Returns
- pointer to the acquired ModuleInstance if success. Error otherwise.
Definition at line 68 of file runtime_instances_pool.cpp.
constexpr size_t kagome::runtime::RuntimeInstancesPool::MODULES_CACHE_SIZE = 2 |
|
staticprivate |
std::mutex kagome::runtime::RuntimeInstancesPool::mt_ |
|
private |
The documentation for this class was generated from the following files: