我正在尝试将 aboost::lockfree::spsc_queue与此websocket 服务器一起使用,而不是使用std::queueform_actions来包含此内容struct:
enum action_type {
SUBSCRIBE,
UNSUBSCRIBE,
MESSAGE
};
struct action {
action(action_type t, connection_hdl h) : type(t), hdl(h) {}
action(action_type t, server::message_ptr m) : type(t), msg(m) {}
action_type type;
websocketpp::connection_hdl hdl;
server::message_ptr msg;
};
我无法初始化这个struct内联
action a = m_actions.front();
因为spsc_queue没有该功能,但用于void pop设置对象和return booleanfor 循环。
当我尝试
action a;
while(m_actions.pop(a)){
...
gcc说:
position_server.cpp:106:11: error: no matching function for call to ‘action::action()’
position_server.cpp:106:11: note: candidates are:
position_server.cpp:39:5: note: action::action(action_type, websocketpp::endpoint<websocketpp::connection<websocketpp::config::asio>, websocketpp::config::asio>::message_ptr)
position_server.cpp:39:5: note: candidate expects 2 arguments, 0 provided
position_server.cpp:38:5: note: action::action(action_type, websocketpp::connection_hdl)
position_server.cpp:38:5: note: candidate expects 2 arguments, 0 provided
position_server.cpp:37:8: note: action::action(const action&)
position_server.cpp:37:8: note: candidate expects 1 argument, 0 provided
如何action构造然后用 设置spsc_queue.pop()?