Autobanh|Cpp 和 Boost::when_all 综合期货

Autobanh|Cpp and Boost::when_all composite futures

在过去的一个月里,我一直在研究 WAMP 和 Autobanh|Cpp,我决定开始试验。我已经成功安装了 Autobahn 并从 this 克隆了 Autobahn|Cpp 库(和示例)。 但是构建示例(使用 Scons)似乎存在问题。示例 call2.cpp 依赖于使用 'when_all' 的 Boost 复合期货,在继续之前等待一个或所有组合操作完成。

从控制台输出来看,似乎 'when_all' 未声明:

fguertin@BBBRTH5DEV01:~/Desktop/AutobahnCpp$ scons
scons: Reading SConscript files ...
Using GNU toolchain
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/examples/call2.o -c -std=c++11 -O2 -Wall -pedantic -Wno-deprecate-declarations -Wno-unused-local-typedefs -Wl,--no-as-needed -pthread -I/home/fguertin/boost_1_55_0-x86 -I/home/fguertin/msgpack-c/include -Iautobahn examples/call2.cpp
examples/call2.cpp: In lambda function:
examples/call2.cpp:128:85: error: 'when_all' was not declared in this scope
               auto finish = when_all(std::move(c0), std::move(c1), std::move(c2));
                             ^
In file included from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/impl/posix_event.ipp:24:0,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/posix_event.hpp:95,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/event.hpp:25,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/task_io_service_thread_info.hpp:18,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/impl/handler_alloc_hook.ipp:26,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/handler_alloc_hook.hpp:80,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/handler_alloc_helpers.hpp:21,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/bind_handler.hpp:19,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/detail/wrapped_handler.hpp:18,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/io_service.hpp:24,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/basic_io_object.hpp:19,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/basic_socket.hpp:20,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio/basic_datagram_socket.hpp:20,
                 from /home/fguertin/boost_1_55_0-x86/boost/asio.hpp:21,
                 from autobahn/autobahn.hpp:42,
                 from examples/call2.cpp:31:

我只是想知道为什么这不起作用,我错过了什么。

你有

#define BOOST_THREAD_PROVIDES_FUTURE
#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
#define BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY

或相应的编译器标志?

您的 Boost 太旧了。参见 here and here。您至少需要 1.56.

另外(没有必要,但是):帮自己一个忙,使用 decent compiler;)