I am trying to use boost::lockfree::spsc_queue with this websocket server instead of std::queue for m_actions to contain this 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; };
I cannot initialize this struct inline with
action a = m_actions.front();
because spsc_queue does not have this function, but uses void pop to set the object and return boolean for the loop.
When i try
action a; while(m_actions.pop(a)){ ...
gcc says:
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
How can I build an action and then set using spsc_queue.pop() ?
user1382306
source share