mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated smartcontracts
- updated smartcontracts - updated fullnode database layout - fixed memory leak in blockchain-explorer - updated tonlib
This commit is contained in:
parent
9c9248a9ae
commit
c860ce3d1e
104 changed files with 7309 additions and 1335 deletions
|
@ -225,6 +225,7 @@ class Promise {
|
|||
promise_->set_error(std::move(error));
|
||||
promise_.reset();
|
||||
}
|
||||
|
||||
void set_result(Result<T> &&result) {
|
||||
if (!promise_) {
|
||||
return;
|
||||
|
@ -260,6 +261,28 @@ class Promise {
|
|||
explicit operator bool() {
|
||||
return static_cast<bool>(promise_);
|
||||
}
|
||||
template <class V, class F>
|
||||
auto do_wrap(V &&value, F &&func) {
|
||||
if (value.is_ok()) {
|
||||
set_result(func(value.move_as_ok()));
|
||||
} else {
|
||||
set_error(value.move_as_error());
|
||||
}
|
||||
}
|
||||
|
||||
template <class F>
|
||||
auto do_wrap(td::Status status, F &&func) {
|
||||
set_error(std::move(status));
|
||||
}
|
||||
|
||||
template <class F>
|
||||
auto wrap(F &&func) {
|
||||
return [promise = std::move(*this), func = std::move(func)](auto &&res) mutable {
|
||||
promise.do_wrap(std::move(res), std::move(func));
|
||||
};
|
||||
}
|
||||
template <class... ArgsT>
|
||||
auto send_closure(ArgsT &&... args);
|
||||
|
||||
private:
|
||||
std::unique_ptr<PromiseInterface<T>> promise_;
|
||||
|
|
|
@ -162,4 +162,29 @@ void send_signals_later(ActorIdT &&actor_id, ActorSignals signals) {
|
|||
detail::send_signals_later(id.as_actor_ref(), signals);
|
||||
}
|
||||
} // namespace actor
|
||||
|
||||
class SendClosure {
|
||||
public:
|
||||
template <class... ArgsT>
|
||||
void operator()(ArgsT &&... args) const {
|
||||
td::actor::send_closure(std::forward<ArgsT>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
template <class... ArgsT>
|
||||
auto Promise<T>::send_closure(ArgsT &&... args) {
|
||||
return [promise = std::move(*this), t = std::make_tuple(std::forward<ArgsT>(args)...)](auto &&r_res) mutable {
|
||||
TRY_RESULT_PROMISE(promise, res, std::move(r_res));
|
||||
td::call_tuple(SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::move(res), std::move(promise))));
|
||||
};
|
||||
}
|
||||
|
||||
template <class... ArgsT>
|
||||
auto promise_send_closure(ArgsT &&... args) {
|
||||
return [t = std::make_tuple(std::forward<ArgsT>(args)...)](auto &&res) mutable {
|
||||
td::call_tuple(SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::move(res))));
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue