载入中...
搜索中...
未找到
eve::transaction::AtomicBatch类 参考final

Single-use composition of domain participants and one payer's costs. Owns staged participants, never game state. Domain producers add independent effects; payment is merged and committed once through the existing coordinator. Script bindings retain each domain facade until commit/destruction. Entity participants must revalidate handles at prepare/commit. VM owners must outlive this batch; all calls run on the same VM/simulation owner thread without reentry. No script callbacks run during commit. This transient builder is not serializable. 更多...

#include <AtomicBatch.h>

类

struct  Impl
 

Public 成员函数

 AtomicBatch ()
 Create an empty owner-thread batch.
 
 ~AtomicBatch ()
 Release uncommitted stages and retained script owners.
 
 AtomicBatch (const AtomicBatch &)=delete
 
AtomicBatch & operator= (const AtomicBatch &)=delete
 
Result< void > add (std::vector< std::unique_ptr< ITransactionParticipant > > effects, std::optional< resource::CostSpec > cost={})
 Append owning effects and optional cost without executing them. @cost Linear in effect/cost count; staging amortizes allocation per request.
 
Result< void > bindAccount (resource::IResourceAccount &account, std::function< std::optional< Value >(std::string_view)> query={})
 Select the authoritative payer; a different second payer is rejected. @ownership Borrowed account; native callers retain it through commit. Script producers retain the owning facade using retainScriptOwner.
 
Result< void > bindAccount (std::shared_ptr< resource::IResourceAccount > account, std::function< std::optional< Value >(std::string_view)> query={})
 Retain a protocol adapter while its balance owner remains authoritative.
 
Result< void > guard (std::function< Result< void >()> validate)
 Add a synchronous read-only lifetime/time precondition. Guards run before account access; scripts cannot supply arbitrary callbacks.
 
Result< void > protect (resource::ResourceCost floor)
 Preserve a resource floor after the complete merged payment. Multiple contributors combine floors by maximum, not by summing them.
 
Result< void > reject (Status status)
 Preserve the first admission error and reject further execution.
 
std::optional< Value > resource (std::string_view name) const
 Query the selected authoritative account for condition evaluation.
 
Result< TransactionReceipt > commit ()
 Commit all stages once, or roll back/compensate via Coordinator. @cost Linear in stages plus their domain preparation costs; one reservation per batch amortizes payment across all effects. Consumes the builder.
 
Result< void > retainScriptOwner (void *vm)
 Retain the current native script method's self for staged lifetimes.
 

静态 Public 成员函数

static Result< resource::CostSpec > parseCost (const std::string &json)
 Parse a positive-integer resource cost object at the script boundary.
 

详细描述

Single-use composition of domain participants and one payer's costs. Owns staged participants, never game state. Domain producers add independent effects; payment is merged and committed once through the existing coordinator. Script bindings retain each domain facade until commit/destruction. Entity participants must revalidate handles at prepare/commit. VM owners must outlive this batch; all calls run on the same VM/simulation owner thread without reentry. No script callbacks run during commit. This transient builder is not serializable.

在文件 AtomicBatch.h 第 19 行定义.

构造及析构函数说明

◆ AtomicBatch() [1/2]

eve::transaction::AtomicBatch::AtomicBatch ( )

Create an empty owner-thread batch.

在文件 AtomicBatch.cpp 第 23 行定义.

◆ ~AtomicBatch()

eve::transaction::AtomicBatch::~AtomicBatch ( )
default

Release uncommitted stages and retained script owners.

◆ AtomicBatch() [2/2]

eve::transaction::AtomicBatch::AtomicBatch ( const AtomicBatch &  )
delete

成员函数说明

◆ add()

Result< void > eve::transaction::AtomicBatch::add ( std::vector< std::unique_ptr< ITransactionParticipant > >  effects,
std::optional< resource::CostSpec >  cost = {} 
)

Append owning effects and optional cost without executing them. @cost Linear in effect/cost count; staging amortizes allocation per request.

返回
Failure poisons the batch so an ignored staging error cannot commit.

在文件 AtomicBatch.cpp 第 88 行定义.

引用了 eve::Conflict, cost, eve::resource::CostSpec::create(), effect, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Status::failure(), eve::InvalidArgument, eve::resource::CostSpec::items(), reject() , 以及 eve::Result< T >::success().

被这些函数引用 eve::rts::script_internal::exposeStageBindings() , 以及 eve::card::Card::stagePlay().

◆ bindAccount() [1/2]

Result< void > eve::transaction::AtomicBatch::bindAccount ( resource::IResourceAccount &  account,
std::function< std::optional< Value >(std::string_view)>  query = {} 
)

Select the authoritative payer; a different second payer is rejected. @ownership Borrowed account; native callers retain it through commit. Script producers retain the owning facade using retainScriptOwner.

在文件 AtomicBatch.cpp 第 29 行定义.

引用了 account, eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Status::failure(), reject() , 以及 eve::Result< T >::success().

被这些函数引用 bindAccount().

◆ bindAccount() [2/2]

Result< void > eve::transaction::AtomicBatch::bindAccount ( std::shared_ptr< resource::IResourceAccount >  account,
std::function< std::optional< Value >(std::string_view)>  query = {} 
)

Retain a protocol adapter while its balance owner remains authoritative.

在文件 AtomicBatch.cpp 第 39 行定义.

引用了 account, bindAccount(), eve::Diagnostic::error(), eve::Status::failure(), eve::InvalidArgument, reject() , 以及 eve::Result< T >::success().

◆ commit()

Result< TransactionReceipt > eve::transaction::AtomicBatch::commit ( )

Commit all stages once, or roll back/compensate via Coordinator. @cost Linear in stages plus their domain preparation costs; one reservation per batch amortizes payment across all effects. Consumes the builder.

在文件 AtomicBatch.cpp 第 144 行定义.

引用了 eve::Conflict, context, cost, eve::resource::CostSpec::create(), effect, eve::Diagnostic::error(), eve::transaction::AtomicResourcePayment::execute(), eve::Result< T >::failure(), guard(), eve::InvalidArgument, name, eve::PreconditionViolation, result , 以及 valid.

被这些函数引用 eve::transaction::script_internal::exposeAtomicBatch().

◆ guard()

Result< void > eve::transaction::AtomicBatch::guard ( std::function< Result< void >()>  validate)

Add a synchronous read-only lifetime/time precondition. Guards run before account access; scripts cannot supply arbitrary callbacks.

在文件 AtomicBatch.cpp 第 68 行定义.

引用了 eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Status::failure(), reject() , 以及 eve::Result< T >::success().

被这些函数引用 commit() , 以及 resource().

◆ operator=()

AtomicBatch & eve::transaction::AtomicBatch::operator= ( const AtomicBatch &  )
delete

◆ parseCost()

Result< resource::CostSpec > eve::transaction::AtomicBatch::parseCost ( const std::string &  json)
static

◆ protect()

◆ reject()

Result< void > eve::transaction::AtomicBatch::reject ( Status  status)

Preserve the first admission error and reject further execution.

在文件 AtomicBatch.cpp 第 25 行定义.

引用了 eve::Result< T >::failure() , 以及 status.

被这些函数引用 add(), bindAccount(), bindAccount(), eve::rts::script_internal::exposeStageBindings(), guard(), protect(), retainScriptOwner() , 以及 eve::card::Card::stagePlay().

◆ resource()

std::optional< Value > eve::transaction::AtomicBatch::resource ( std::string_view  name) const

Query the selected authoritative account for condition evaluation.

在文件 AtomicBatch.cpp 第 107 行定义.

引用了 guard(), name , 以及 valid.

◆ retainScriptOwner()

Result< void > eve::transaction::AtomicBatch::retainScriptOwner ( void *  vm)

Retain the current native script method's self for staged lifetimes.

参数
vmOpaque Squirrel VM handle on the current owner thread.
返回
Failure if the builder is consumed or VM self cannot be retained.

在文件 AtomicBatch.cpp 第 115 行定义.

引用了 eve::Conflict, eve::Diagnostic::error(), eve::Status::failure(), handle, eve::InvalidArgument, reject(), eve::Result< T >::success(), top , 以及 vm.

被这些函数引用 eve::card::card_internal::exposeStageBindings() , 以及 eve::rts::script_internal::exposeStageBindings().


该类的文档由以下文件生成: