本文整理汇总了C++中threadpool类的典型用法代码示例。如果您正苦于以下问题:C++ threadpool类的具体用法?C++ threadpool怎么用?C++ threadpool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了threadpool类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
channel_proxy::channel_proxy(threadpool& pool, socket_ptr socket)
: strand_(pool.service()), socket_(socket),
timeout_(pool.service()), heartbeat_(pool.service()), stopped_(false)
{
#define CHANNEL_TRANSPORT_MECHANISM(MESSAGE_TYPE) \
MESSAGE_TYPE##_subscriber_ = \
std::make_shared<MESSAGE_TYPE##_subscriber_type>(pool); \
loader_.add(new channel_loader_module<MESSAGE_TYPE##_type>( \
std::bind(&MESSAGE_TYPE##_subscriber_type::relay, \
MESSAGE_TYPE##_subscriber_, _1, _2)));
CHANNEL_TRANSPORT_MECHANISM(version);
CHANNEL_TRANSPORT_MECHANISM(verack);
CHANNEL_TRANSPORT_MECHANISM(address);
CHANNEL_TRANSPORT_MECHANISM(get_address);
CHANNEL_TRANSPORT_MECHANISM(inventory);
CHANNEL_TRANSPORT_MECHANISM(get_data);
CHANNEL_TRANSPORT_MECHANISM(get_blocks);
CHANNEL_TRANSPORT_MECHANISM(transaction);
CHANNEL_TRANSPORT_MECHANISM(block);
#undef CHANNEL_TRANSPORT_MECHANISM
raw_subscriber_ = std::make_shared<raw_subscriber_type>(pool);
stop_subscriber_ = std::make_shared<stop_subscriber_type>(pool);
}
开发者ID:hsk81,项目名称:libbitcoin,代码行数:26,代码来源:channel.cpp
示例2:
connector::connector(threadpool& pool, const settings& settings)
: pool_(pool),
settings_(settings),
resolver_(std::make_shared<asio::resolver>(pool.service())),
CONSTRUCT_TRACK(connector, LOG_NETWORK)
{
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:7,代码来源:connector.cpp
示例3:
protocol::protocol(threadpool& pool, hosts& hsts,
handshake& shake, network& net)
: strand_(pool), hosts_(hsts), handshake_(shake), network_(net),
watermark_timer_(pool.service())
{
channel_subscribe_ = std::make_shared<channel_subscriber_type>(pool);
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:7,代码来源:protocol.cpp
示例4:
session::session(threadpool& pool, const session_params& params)
: strand_(pool.service()),
handshake_(params.handshake_), protocol_(params.protocol_),
chain_(params.blockchain_), poll_(params.poller_),
tx_pool_(params.transaction_pool_),
grabbed_invs_(20)
{
}
开发者ID:hellais,项目名称:libbitcoin,代码行数:8,代码来源:session.cpp
示例5: print_tp_status
void print_tp_status(threadpool &tp) {
std::stringstream ss;
for(u_int i=0;i<num_threads;i++){
std::string status = tp.get_thread_status(i);
if(status.size() && status!="Free"){
ss << "Thread " << i << ": " << status << "\n";
}
}
std::cout << ss.str() << "\n";
}
开发者ID:endeav0r,项目名称:bulk_extractor,代码行数:10,代码来源:bulk_extractor.cpp
示例6:
connector::connector(threadpool& pool, const settings& settings)
: stopped_(false),
pool_(pool),
settings_(settings),
pending_(settings_),
dispatch_(pool, NAME),
resolver_(std::make_shared<asio::resolver>(pool.service())),
CONSTRUCT_TRACK(connector)
{
}
开发者ID:libbitcoin,项目名称:libbitcoin-network,代码行数:10,代码来源:connector.cpp
示例7:
work::work(threadpool& pool, const std::string& name)
: name_(name),
////ordered_(std::make_shared<monitor::count>(0)),
////unordered_(std::make_shared<monitor::count>(0)),
////concurrent_(std::make_shared<monitor::count>(0)),
////sequential_(std::make_shared<monitor::count>(0)),
service_(pool.service()),
strand_(service_),
sequence_(service_)
{
}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:11,代码来源:work.cpp
示例8:
blockchain_impl::blockchain_impl(threadpool& pool, const std::string& prefix,
const db_active_heights &active_heights, size_t orphan_capacity)
: ios_(pool.service()), write_strand_(pool), reorg_strand_(pool),
flock_(init_lock(prefix)), seqlock_(0), stopped_(false), db_paths_(prefix),
interface_(db_paths_, active_heights), orphans_(orphan_capacity),
chain_(simple_chain_impl(interface_)),
reorganize_subscriber_(std::make_shared<reorganize_subscriber_type>(pool)),
organizer_(organizer_factory(reorg_strand_, interface_, orphans_, chain_,
reorganize_subscriber_))
{
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-blockchain,代码行数:11,代码来源:blockchain_impl.cpp
示例9: log_error
void fullnode::stop()
{
std::promise<std::error_code> ec_promise;
auto session_stopped =
[&ec_promise](const std::error_code& ec)
{
ec_promise.set_value(ec);
};
session_.stop(session_stopped);
std::error_code ec = ec_promise.get_future().get();
if (ec)
log_error() << "Problem stopping session: " << ec.message();
// Stop threadpools.
net_pool_.stop();
disk_pool_.stop();
mem_pool_.stop();
// Join threadpools. Wait for them to finish.
net_pool_.join();
disk_pool_.join();
mem_pool_.join();
// Safely close blockchain database.
chain_.stop();
}
开发者ID:lclc,项目名称:libbitcoin,代码行数:25,代码来源:fullnode.cpp
示例10: rand
handshake::handshake(threadpool& pool)
: strand_(pool.service())
{
// Setup template version packet with defaults
template_version_.version = protocol_version;
template_version_.services = 1;
// non-constant field
//template_version_.timestamp = time(NULL);
template_version_.address_me.services = template_version_.services;
template_version_.address_me.ip = localhost_ip();
template_version_.address_me.port = protocol_port;
template_version_.address_you.services = template_version_.services;
template_version_.address_you.ip =
ip_address_type{{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x01}};
template_version_.address_you.port = protocol_port;
template_version_.user_agent = "/libbitcoin:" LIBBITCOIN_VERSION "/";
template_version_.start_height = 0;
template_version_.nonce = rand();
}
开发者ID:Mrkebubun,项目名称:libbitcoin,代码行数:20,代码来源:handshake.cpp
示例11: rand
handshake::handshake(threadpool& pool, p2p_network p2p)
: strand_(pool.service()), p2p_(p2p)
{
// Setup template version packet with defaults
template_version_.version = protocol_version;
template_version_.services = 1;
// non-constant field
//template_version_.timestamp = time(NULL);
template_version_.address_me.services = template_version_.services;
template_version_.address_me.ip = localhost_ip();
template_version_.address_me.port = p2p_.get_port();
template_version_.address_you.services = template_version_.services;
template_version_.address_you.ip =
ip_address_type{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x01 } };
template_version_.address_you.port = p2p_.get_port();
template_version_.user_agent = "/decentralised:" DC_CORE_LIB_VERSION "/";
template_version_.start_height = 0;
template_version_.nonce = rand();
}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:20,代码来源:handshake.cpp
示例12:
async_strand::async_strand(threadpool& pool)
: ios_(pool.service()), strand_(ios_)
{
}
开发者ID:hsk81,项目名称:libbitcoin,代码行数:4,代码来源:threadpool.cpp
示例13:
leveldb_blockchain::leveldb_blockchain(threadpool& pool)
: ios_(pool.service()), strand_(pool), reorg_strand_(pool), seqlock_(0)
{
reorganize_subscriber_ =
std::make_shared<reorganize_subscriber_type>(pool);
}
开发者ID:favioflamingo,项目名称:libbitcoin,代码行数:6,代码来源:leveldb_blockchain.cpp
示例14:
// This protects timer_ against concurrent access with no chance of deadlock.
// This can be dereferenced with an outstanding callback because the timer
// closure captures an instance of this class and the callback.
// This is guaranteed to call handler exactly once unless canceled or reset.
deadline::deadline(threadpool& pool, const asio::duration duration)
: duration_(duration),
timer_(pool.service()),
CONSTRUCT_TRACK(deadline)
{
}
开发者ID:bankonca,项目名称:libbitcoin,代码行数:10,代码来源:deadline.cpp
示例15: subscriber
subscriber(threadpool& pool)
: strand_(pool.service())
{
}
开发者ID:bitkevin,项目名称:libbitcoin,代码行数:4,代码来源:subscriber.hpp
示例16: perform_connect_with_timeout
perform_connect_with_timeout(threadpool& pool)
: timer_(pool.service())
{
socket_ = std::make_shared<tcp::socket>(pool.service());
proxy_ = std::make_shared<channel_proxy>(pool, socket_);
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:6,代码来源:network.cpp
示例17:
poller::poller(threadpool& pool, blockchain& chain)
: strand_(pool.service()), chain_(chain),
last_locator_begin_(null_hash), last_hash_stop_(null_hash),
last_block_hash_(null_hash)
{
}
开发者ID:standardcrypto,项目名称:libbitcoin,代码行数:6,代码来源:poller.cpp
注:本文中的threadpool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论