Kagome
Polkadot Runtime Engine in C++17
kagome::runtime::BorrowedInstance Class Reference

Wrapper type over sptr<ModuleInstance>. Allows to return instance back to the ModuleInstancePool upon destruction of BorrowedInstance. More...

Inheritance diagram for kagome::runtime::BorrowedInstance:
Collaboration diagram for kagome::runtime::BorrowedInstance:

Public Member Functions

 BorrowedInstance (std::weak_ptr< RuntimeInstancesPool > pool, const RuntimeInstancesPool::RootHash &state, std::shared_ptr< ModuleInstance > instance)
 
 ~BorrowedInstance ()
 
const common::Hash256getCodeHash () const override
 
outcome::result< PtrSizecallExportFunction (std::string_view name, common::BufferView encoded_args) const override
 
outcome::result< std::optional< WasmValue > > getGlobal (std::string_view name) const override
 
void forDataSegment (DataSegmentProcessor const &callback) const override
 
InstanceEnvironment const & getEnvironment () const override
 
outcome::result< void > resetEnvironment () override
 
- Public Member Functions inherited from kagome::runtime::ModuleInstance
virtual ~ModuleInstance ()=default
 

Private Attributes

std::weak_ptr< RuntimeInstancesPoolpool_
 
RuntimeInstancesPool::RootHash state_
 
std::shared_ptr< ModuleInstanceinstance_
 

Additional Inherited Members

- Public Types inherited from kagome::runtime::ModuleInstance
using SegmentOffset = size_t
 
using SegmentData = gsl::span< const uint8_t >
 
using DataSegmentProcessor = std::function< void(SegmentOffset, SegmentData)>
 

Detailed Description

Wrapper type over sptr<ModuleInstance>. Allows to return instance back to the ModuleInstancePool upon destruction of BorrowedInstance.

Definition at line 21 of file runtime_instances_pool.cpp.

Constructor & Destructor Documentation

kagome::runtime::BorrowedInstance::BorrowedInstance ( std::weak_ptr< RuntimeInstancesPool pool,
const RuntimeInstancesPool::RootHash state,
std::shared_ptr< ModuleInstance instance 
)
inline

Definition at line 23 of file runtime_instances_pool.cpp.

kagome::runtime::BorrowedInstance::~BorrowedInstance ( )
inline

Definition at line 29 of file runtime_instances_pool.cpp.

Member Function Documentation

outcome::result<PtrSize> kagome::runtime::BorrowedInstance::callExportFunction ( std::string_view  name,
common::BufferView  encoded_args 
) const
inlineoverridevirtual

Call the instance's function

Parameters
name- name of the function
args- a pointer-size describing a buffer with the function parameters
Returns
a pointer-size with the buffer returned by the call

Implements kagome::runtime::ModuleInstance.

Definition at line 39 of file runtime_instances_pool.cpp.

void kagome::runtime::BorrowedInstance::forDataSegment ( DataSegmentProcessor const &  callback) const
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 49 of file runtime_instances_pool.cpp.

const common::Hash256& kagome::runtime::BorrowedInstance::getCodeHash ( ) const
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 35 of file runtime_instances_pool.cpp.

InstanceEnvironment const& kagome::runtime::BorrowedInstance::getEnvironment ( ) const
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 53 of file runtime_instances_pool.cpp.

outcome::result<std::optional<WasmValue> > kagome::runtime::BorrowedInstance::getGlobal ( std::string_view  name) const
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 44 of file runtime_instances_pool.cpp.

outcome::result<void> kagome::runtime::BorrowedInstance::resetEnvironment ( )
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 57 of file runtime_instances_pool.cpp.

Member Data Documentation

std::shared_ptr<ModuleInstance> kagome::runtime::BorrowedInstance::instance_
private

Definition at line 64 of file runtime_instances_pool.cpp.

std::weak_ptr<RuntimeInstancesPool> kagome::runtime::BorrowedInstance::pool_
private

Definition at line 62 of file runtime_instances_pool.cpp.

RuntimeInstancesPool::RootHash kagome::runtime::BorrowedInstance::state_
private

Definition at line 63 of file runtime_instances_pool.cpp.


The documentation for this class was generated from the following file: