本文整理汇总了C++中asio::io_service::run方法的典型用法代码示例。如果您正苦于以下问题:C++ io_service::run方法的具体用法?C++ io_service::run怎么用?C++ io_service::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asio::io_service
的用法示例。
在下文中一共展示了io_service::run方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: system_timer_custom_allocation_test
void system_timer_custom_allocation_test()
{
static asio::io_service io_service;
struct timer
{
asio::system_timer t;
timer() : t(io_service) {}
} timers[100];
int allocation_count = 0;
for (int i = 0; i < 50; ++i)
{
timers[i].t.expires_at((asio::system_timer::time_point::max)());
timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
}
for (int i = 50; i < 100; ++i)
{
timers[i].t.expires_at((asio::system_timer::time_point::min)());
timers[i].t.async_wait(custom_allocation_timer_handler(&allocation_count));
}
for (int i = 0; i < 50; ++i)
timers[i].t.cancel();
io_service.run();
ASIO_CHECK(allocation_count == 0);
}
示例2: ex_flickr
void ex_flickr()
{
printf ("Tags (default 'kitten'): ");
std::string tags = util::readLine();
std::vector<std::string> splitTags;
boost::split(splitTags, tags, boost::is_space());
splitTags.resize(
std::remove(splitTags.begin(), splitTags.end(), "") - splitTags.begin());
if (splitTags.empty())
splitTags.push_back("kitten");
ut::Task<void> task = asyncFlickrDownload(splitTags, 25, 10);
sIo.run();
assert(task.isReady());
try {
task.get();
} catch (std::exception& e) {
printf ("Flickr download failed: %s - %s\n", typeid(e).name(), e.what());
} catch (...) {
printf ("Flickr download failed: unknown exception\n");
}
}
示例3: process_service_work
void scheduler::process_service_work(asio::io_service& service) {
while (running) {
try {
service.run();
} catch (std::exception& e) {
(void) e;
STATICLIB_PION_LOG_ERROR(log, e.what());
} catch (...) {
STATICLIB_PION_LOG_ERROR(log, "caught unrecognized exception");
}
}
}
示例4: IOServiceRunThread
DWORD CALLBACK IOServiceRunThread(void *state)
{
io_service.run();
::SetEvent(io_sync_mutex);
return 0;
}
示例5: io_service_thread
void io_service_thread() {
io_svc.run();
if(log_level) std::cerr << "io_svc stopped" << std::endl;
serial.close(); //serial port should be closed from the same thread as io service
}
示例6: run
void run(size_t n, ThreadGroup& tg) {
tg.run([this]{
asio::io_service::work work(io_service);
io_service.run();
}, n);
}
示例7: run_ios
void run_ios( ba::io_service &ios )
{
while( 1 ) {
ios.run( );
}
}