当前位置: 首页>>代码示例>>C++>>正文


C++ io_service::post方法代码示例

本文整理汇总了C++中boost::asio::io_service::post方法的典型用法代码示例。如果您正苦于以下问题:C++ io_service::post方法的具体用法?C++ io_service::post怎么用?C++ io_service::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::asio::io_service的用法示例。


在下文中一共展示了io_service::post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetId

void
AsyncDBCreateGame::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
{
	query.reset();
	query
			<< "SELECT LAST_INSERT_ID()";
	mysqlpp::StoreQueryResult tmpResult = query.store();
	DB_id insertId = tmpResult[0][0];
	if (!tmpResult || tmpResult.num_rows() != 1 || insertId == 0) {
		service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
	} else {
		service.post(boost::bind(&ServerDBCallback::CreateGameSuccess, &cb, GetId()));
		idManager.AddGameId(GetId(), insertId);
	}
}
开发者ID:pokerth,项目名称:pokerth,代码行数:15,代码来源:asyncdbcreategame.cpp

示例2: push_job

void push_job(int seconds, boost::asio::io_service& io_service, std::vector<boost::shared_future<int> >& pending_data)
{
    boost::shared_ptr<task_t> task = boost::make_shared<task_t>(boost::bind(&sleep_print, seconds));
    boost::shared_future<int> fut(task->get_future());
    pending_data.push_back(fut);
    io_service.post(boost::bind(&task_t::operator(), task));
}
开发者ID:phrocker,项目名称:apeirogon,代码行数:7,代码来源:test.cpp

示例3: iopost_msg

static void iopost_msg(boost::asio::io_service & io_service,
	boost::function<void(std::string)> msg_sender,
	std::string msg, std::string groupid)
{
	io_service.post(boost::bind(msg_sender, msg));
	logfile.add_log(groupid, msg);
}
开发者ID:kikidong,项目名称:avbot,代码行数:7,代码来源:botctl.cpp

示例4: Server

 Server(boost::asio::io_service& io_service)
   : io_service(io_service), data_strand(io_service), active(0),
     sock(io_service, udp::endpoint(udp::v4(), 12321)),
     recv_timer(io_service), send_timer(io_service), msg_timer(io_service) {
   for(auto& p : players){
     p.present = false;
     p.pos = glm::vec3(1.0, 1.0, 1.0);
   }
   start_receive();
   io_service.post(
     data_strand.wrap(std::bind(&Server::respond, this)));
   io_service.post(
     data_strand.wrap(std::bind(&Server::broadcast, this)));
   io_service.post(
     data_strand.wrap(std::bind(&Server::send_msg, this)));
 }
开发者ID:x0rpd,项目名称:rotmeshfps,代码行数:16,代码来源:server.cpp

示例5: push

 std::pair<size_t, size_t> push(pair_type && pair, boost::asio::io_service & main_service)
 {
     auto empty = _sessions.empty();
     _sessions.push(std::move(pair));
     if (empty)
         main_service.post(std::bind(&auth_queue::next, this));
     return { _sessions.size(), _counter };
 }
开发者ID:Ryuuke,项目名称:desperion,代码行数:8,代码来源:auth_queue.hpp

示例6: avlog_do_search

void avlog_do_search(boost::asio::io_service & io_service,
	std::string c, std::string q, std::string date,
	boost::function<void (boost::system::error_code, pt::ptree)> handler,
	soci::session & db)
{
	pt::ptree outjson;
	std::string q_escaped;
	// 根据 channel_name , query string , date 像数据库查找
	AVLOG_DBG << " c = " << c << " q =  " << q << " date= " << date ;

	std::vector<std::string>	r_date(1000);
	std::vector<std::string>	r_channel(1000);
	std::vector<std::string>	r_nick(1000);
	std::vector<std::string>	r_message(1000);
	std::vector<std::string>	r_rowid(1000);

	avhttp::detail::unescape_path(q, q_escaped);

	boost::timer::cpu_timer cputimer;

	cputimer.start();

	db << "select date,channel,nick,message,rowid from avlog where channel=:c "
		"and message like \"%" << q_escaped << "%\" order  by strftime(`date`) DESC"
		, soci::into(r_date)
		, soci::into(r_channel)
		, soci::into(r_nick)
		, soci::into(r_message)
		, soci::into(r_rowid)
		, soci::use(c);

	pt::ptree results;
	// print out the result
	for (int i = 0; i < r_date.size() ; i ++)
	{
		pt::ptree onemsg;
		onemsg.put("date", r_date[i]);
		onemsg.put("channel", r_channel[i]);
		onemsg.put("nick", r_nick[i]);
		onemsg.put("channel", r_channel[i]);
		onemsg.put("message", r_message[i]);
		onemsg.put("id", r_rowid[i]);

		results.push_back(std::make_pair("", onemsg));
	}

	outjson.put("params.num_results", r_date.size());
	outjson.put_child("data", results);

	outjson.put("params.time_used", boost::timer::format(cputimer.elapsed(), 6, "%w"));

	io_service.post(
		boost::asio::detail::bind_handler(handler,
			boost::system::error_code(),
			outjson
		)
	);
};
开发者ID:AimuTran,项目名称:avbot,代码行数:58,代码来源:avbot_log_search.cpp

示例7:

void
Logger::finalizeLogRecord()
{
    if (!recordsQueue_.push(currentLogRecord_.str()))
        sink_->finalizeRecord("[CRITICAL]\tlog queue is full");
        // getOutFileStream() << "[CRITICAL]\tlog queue is full" << std::endl;
    else
        LogIoService.post(boost::bind(&Logger::processLogRecords, shared_from_this()));
}
开发者ID:remap,项目名称:ndnrtc,代码行数:9,代码来源:simple-log.cpp

示例8: worker

void worker(int id) {
    while (true) {
        this_thread::sleep_for(chrono::milliseconds(rand() % 3000));

        shared_queue.post([id] {
                std::cout << "event from thread #" << id << " handled on " << this_thread::get_id << "\n";
            });
    }
}
开发者ID:CCJY,项目名称:coliru,代码行数:9,代码来源:main.cpp

示例9: job_func

/*
 * NOTE!!! post dispatch 区别仅仅在io_service调用的工作函数里使用才看得出区别。
 * dispatch 只有start没有finish
 */
static
void job_func(int i)
{
    LOG(INFO) << "Job " << i << " started in thread " << THIS_THREAD_ID;
    SLEEP_SECONDS(2);
    // g_io_service.dispatch(std::bind(job_func, i+1));
    g_io_service.post(std::bind(job_func, i+1));
    LOG(INFO) << "Job " << i << " finished in thread " << THIS_THREAD_ID;
}
开发者ID:charles-pku-2013,项目名称:CodeRes_Cpp,代码行数:13,代码来源:post_vs_dispatch.cpp

示例10: main

int main(int argc, char** argv) {
    init();
    if (handle_args(argc, argv) == 1)
        return 0;

    int processors = boost::thread::hardware_concurrency();

    ioService.post(boost::bind(read_images));
    ioService.post(boost::bind(assign_workers));
    ioService.post(boost::bind(output));

    boost::asio::io_service::work work(ioService);
    for (int i = 0; i < processors; i++) {
        threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioService));
    }
    threadpool.join_all();
    return 0;
}
开发者ID:h397wang,项目名称:computer-vision,代码行数:18,代码来源:main.cpp

示例11: syncLoad

		void syncLoad(AssetPath path, AssetPromisePtr pr, AssetContentPtr c) {
			Progress::Work w = (Progress::Work)boost::filesystem::file_size(path);
			mngr.prog_.addWork( w );
			// add the loading function to the io_service
			io.post( boost::bind(
				&AssetManager::Loader::asyncLoad,
				this, path, pr, c, w
				)
			);
		}
开发者ID:cristicbz,项目名称:AdventureMiner,代码行数:10,代码来源:AssetManager.cpp

示例12: input_thread

// workarround windows that can use posix stream for stdin
static void input_thread(boost::asio::io_service & io_service)
{
	while (!boost::this_thread::interruption_requested() && !std::cin.eof())
	{
		std::string line;
		std::getline(std::cin, line);
		io_service.post([line]{
			input_got_one_line(ansi_utf8(line));
		});
	}
}
开发者ID:firstblade,项目名称:avbot,代码行数:12,代码来源:input.cpp

示例13: hello

static void 
worker()
{
    sleep(2);
    svc.post([](){
            std::cout<<"\nRaising signal.";
            std::string hello("hello world");
            textEntered(hello);
       });
    return;
}
开发者ID:CCJY,项目名称:coliru,代码行数:11,代码来源:main.cpp

示例14: main

int main(int argc, char **argv) {

  if (argc != 3) {
    std::cerr << "usage stackless_coroutine_perf <port> <read buffer size>\n";
    return 1;
  }

  boost::asio::io_service io;
  auto work = std::make_unique<boost::asio::io_service::work>(io);

  std::promise<void> done_promise;

  auto done_future = done_promise.get_future();

  auto func = [&]() {
    do_coroutine(io, "127.0.0.1", argv[1], std::stoi(argv[2]),
                 [&](auto &value, std::exception_ptr e, auto op) {
                   if (e) {
                     done_promise.set_exception(e);
                   } else {
                     auto end_time = std::chrono::steady_clock::now();

                     auto duration =
                         std::chrono::duration_cast<std::chrono::milliseconds>(
                             end_time - value.start_time);
                     std::cout << "Received " << value.bytes << " in "
                               << duration.count() << " milliseconds\n";
                     std::cout << "Transmit speed "
                               << (value.bytes / duration.count()) * 1000
                               << " Bytes/Seconds \n";
                     done_promise.set_value();
                   }
                 });
  };

  io.post(func);

  auto frun = std::async(std::launch::async, [&]() { io.run(); });

  done_future.wait();

  work.reset();

  frun.get();

  try {

    done_future.get();
  } catch (std::exception &e) {
    std::cerr << e.what() << "\n";
  }
};
开发者ID:XiaochenFTX,项目名称:stackless_coroutine,代码行数:52,代码来源:stackless_coroutines_perf.cpp

示例15: async_rename

	void async_rename(const boost::filesystem::path & source,
		const boost::filesystem::path & destination,
		Callback callback)
	{
		worker_service_.post(boost::bind(
			&filesystem_service::rename<boost::_bi::protected_bind_t<Callback> >,
			this,
			boost::make_shared<boost::asio::io_service::work>(boost::ref(io_service_)),
			source,
			destination,
			boost::protect(callback)
		));
	}
开发者ID:mpapierski,项目名称:filesystem_service,代码行数:13,代码来源:filesystem_service.hpp


注:本文中的boost::asio::io_service::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。