代码之家  ›  专栏  ›  技术社区  ›  niXman

Asio。期望队列中任何对象完成的可能性是必要的

  •  0
  • niXman  · 技术社区  · 14 年前

    在asio::io_服务中,我插入对象。asio::io_service::run()在多个线程中运行。 期望队列中任何对象完成的可能性是必要的。 例如:

    template <typename T>
    struct handler {
       void operator()() {
          ....
       }
       T get() const {...}
    };
    
    asio::io_service ios;
    ios.post(handler());
    
    1. 如何引用队列中的对象?
    2. 在执行句柄::operator()之前,如何暂停主程序循环?

    谢谢。

    1 回复  |  直到 11 年前
        1
  •  1
  •   skimobear    14 年前