lingbin commented on a change in pull request #2931: Use ThreadPool to refactor MemTableFlushExecutor URL: https://github.com/apache/incubator-doris/pull/2931#discussion_r380573580
########## File path: be/src/olap/memtable_flush_executor.cpp ########## @@ -24,146 +24,62 @@ #include "olap/memtable.h" #include "runtime/exec_env.h" #include "runtime/mem_tracker.h" +#include "util/scoped_cleanup.h" namespace doris { -OLAPStatus FlushHandler::submit(std::shared_ptr<MemTable> memtable) { - RETURN_NOT_OK(_last_flush_status.load()); - MemTableFlushContext ctx; - ctx.memtable = std::move(memtable); - ctx.flush_handler = this->shared_from_this(); - _counter_cond.inc(); - VLOG(5) << "submitting " << *(ctx.memtable) << " to flush queue " << _flush_queue_idx; - RETURN_NOT_OK(_flush_executor->_push_memtable(_flush_queue_idx, ctx)); - return OLAP_SUCCESS; -} - -OLAPStatus FlushHandler::wait() { - // wait all submitted tasks to be finished or cancelled - _counter_cond.block_wait(); - return _last_flush_status.load(); -} - -void FlushHandler::on_flush_finished(const FlushResult& res) { - if (res.flush_status != OLAP_SUCCESS) { - _last_flush_status.store(res.flush_status); - } else { - _stats.flush_time_ns.fetch_add(res.flush_time_ns); - _stats.flush_count.fetch_add(1); - } - _counter_cond.dec(); +std::ostream& operator<<(std::ostream& os, const FlushStatistic& stat) { + os << "(flush time(ms)=" << stat.flush_time_ns / 1000 / 1000 + << ", flush count=" << stat.flush_count << ")"; + return os; } -OLAPStatus MemTableFlushExecutor::create_flush_handler( - size_t path_hash, std::shared_ptr<FlushHandler>* flush_handler) { - size_t flush_queue_idx = _get_queue_idx(path_hash); - flush_handler->reset(new FlushHandler(flush_queue_idx, this)); +OLAPStatus FlushToken::submit(std::shared_ptr<MemTable> memtable) { + _flush_token->submit_func(boost::bind(boost::mem_fn(&FlushToken::_flush_memtable), this, memtable)); Review comment: Could you please use `std::bind` instead? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org