上一篇写了EOS插件间通信,其中就用到了boost里面的信号(boost::signals2::signal),C++1X新特性用多了大佬自然一眼看穿,对我等小白来说,初看的时候自然感觉云里雾里,看久了才发现百变不离其宗,还是那套东西,下面听我细细道来。
还是从chain_plugin.cpp里面的push_transaction说起:
void read_write::push_transaction(const read_write::push_transaction_params& params, next_function<read_write::push_transaction_results> next) {
try {
auto pretty_input = std::make_shared<packed_transaction>();
auto resolver = make_resolver(this, abi_serializer_max_time);
try {
.........
app().get_method<incoming::methods::transaction_async>()(pretty_input, true, [this, next](const fc::static_variant<fc::exception_ptr, transaction_trace_ptr>& result) -> void{
.........
});
} catch ( boost::interprocess::bad_alloc& ) {
raise(SIGUSR1);
} CATCH_AND_CALL(next);
}