- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试替换 boost::lockfree::queue
对于 std::queue
在这个文件中 https://github.com/zaphoyd/websocketpp/blob/experimental/examples/broadcast_server/broadcast_server.cpp
我添加了 #include <boost/lockfree/queue.hpp>
;改线 130
, std::queue<action> m_actions;
, 至 boost::lockfree::queue<action> m_actions;
;删除所有与锁定有关的行;并更改了行 103
, m_actions.pop();
, 至 m_actions.pop(a);
.
我在 scons broadcast_server_lockfree
时遇到这些错误在添加 broadcast_server_lockfree = SConscript('#/broadcast_server_lockfree/SConscript',variant_dir = builddir + 'broadcast_server_lockfree',duplicate = 0)
后的项目根目录中到项目根目录的 SConstruct
并使用 broadcast_server
的 SConstruct
在broadcast_server_lockfree
目录:
root@server:~/websocketpp-experimental# scons broadcast_server_lockfree
scons: Reading SConscript files ...
C++11 build environment partially enabled
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build/release/broadcast_server_lockfree
g++ -o build/release/broadcast_server_lockfree/broadcast_server_lockfree.o -c -std=c++0x -Wall -Wcast-align -isystem /root/boost_1_53_0 -DNDEBUG -D_WEBSOCKETPP_CPP11_MEMORY_ -D_WEBSOCKETPP_CPP11_FUNCTIONAL_ -D_WEBSOCKETPP_CPP11_SYSTEM_ERROR_ -D_WEBSOCKETPP_CPP11_RANDOM_DEVICE_ -D_WEBSOCKETPP_NOEXCEPT_ -I. broadcast_server_lockfree/broadcast_server_lockfree.cpp
In file included from broadcast_server_lockfree/broadcast_server_lockfree.cpp:10:0:
/root/boost_1_53_0/boost/lockfree/queue.hpp: In instantiation of 'class boost::lockfree::queue<action>':
broadcast_server_lockfree/broadcast_server_lockfree.cpp:139:36: required from here
/root/boost_1_53_0/boost/lockfree/queue.hpp:79:5: error: static assertion failed: (boost::has_trivial_destructor<T>::value)
/root/boost_1_53_0/boost/lockfree/queue.hpp:83:5: error: static assertion failed: (boost::has_trivial_assign<T>::value)
broadcast_server_lockfree/broadcast_server_lockfree.cpp: In member function 'void broadcast_server::process_messages()':
broadcast_server_lockfree/broadcast_server_lockfree.cpp:111:34: error: 'class boost::lockfree::queue<action>' has no member named 'front'
broadcast_server_lockfree/broadcast_server_lockfree.cpp:117:55: error: 'm_connection_lock' was not declared in this scope
broadcast_server_lockfree/broadcast_server_lockfree.cpp:120:55: error: 'm_connection_lock' was not declared in this scope
broadcast_server_lockfree/broadcast_server_lockfree.cpp:123:55: error: 'm_connection_lock' was not declared in this scope
In file included from broadcast_server_lockfree/broadcast_server_lockfree.cpp:10:0:
/root/boost_1_53_0/boost/lockfree/queue.hpp: In instantiation of 'boost::lockfree::queue<T, A0, A1, A2>::~queue() [with T = action; A0 = boost::parameter::void_; A1 = boost::parameter::void_; A2 = boost::parameter::void_]':
broadcast_server_lockfree/broadcast_server_lockfree.cpp:41:24: required from here
/root/boost_1_53_0/boost/lockfree/queue.hpp:229:11: error: no matching function for call to 'action::action()'
/root/boost_1_53_0/boost/lockfree/queue.hpp:229:11: note: candidates are:
broadcast_server_lockfree/broadcast_server_lockfree.cpp:32:5: note: action::action(action_type, websocketpp::endpoint<websocketpp::connection<websocketpp::config::asio>, websocketpp::config::asio>::message_ptr)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:32:5: note: candidate expects 2 arguments, 0 provided
broadcast_server_lockfree/broadcast_server_lockfree.cpp:31:5: note: action::action(action_type, websocketpp::connection_hdl)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:31:5: note: candidate expects 2 arguments, 0 provided
broadcast_server_lockfree/broadcast_server_lockfree.cpp:30:8: note: action::action(const action&)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:30:8: note: candidate expects 1 argument, 0 provided
In file included from broadcast_server_lockfree/broadcast_server_lockfree.cpp:10:0:
/root/boost_1_53_0/boost/lockfree/queue.hpp: In instantiation of 'boost::lockfree::queue<T, A0, A1, A2>::node::node(boost::lockfree::queue<T, A0, A1, A2>::node::handle_type) [with T = action; A0 = boost::parameter::void_; A1 = boost::parameter::void_; A2 = boost::parameter::void_; boost::lockfree::queue<T, A0, A1, A2>::node::handle_type = boost::lockfree::queue<action>::node*]':
/root/boost_1_53_0/boost/lockfree/detail/freelist.hpp:82:13: required from 'T* boost::lockfree::detail::freelist_stack<T, Alloc>::construct(const ArgumentType&) [with bool ThreadSafe = true; bool Bounded = false; ArgumentType = boost::lockfree::queue<action>::node*; T = boost::lockfree::queue<action>::node; Alloc = std::allocator<boost::lockfree::queue<action>::node>]'
/root/boost_1_53_0/boost/lockfree/queue.hpp:126:75: required from 'void boost::lockfree::queue<T, A0, A1, A2>::initialize() [with T = action; A0 = boost::parameter::void_; A1 = boost::parameter::void_; A2 = boost::parameter::void_]'
/root/boost_1_53_0/boost/lockfree/queue.hpp:166:9: required from 'boost::lockfree::queue<T, A0, A1, A2>::queue() [with T = action; A0 = boost::parameter::void_; A1 = boost::parameter::void_; A2 = boost::parameter::void_]'
broadcast_server_lockfree/broadcast_server_lockfree.cpp:41:24: required from here
/root/boost_1_53_0/boost/lockfree/queue.hpp:109:52: error: no matching function for call to 'action::action()'
/root/boost_1_53_0/boost/lockfree/queue.hpp:109:52: note: candidates are:
broadcast_server_lockfree/broadcast_server_lockfree.cpp:32:5: note: action::action(action_type, websocketpp::endpoint<websocketpp::connection<websocketpp::config::asio>, websocketpp::config::asio>::message_ptr)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:32:5: note: candidate expects 2 arguments, 0 provided
broadcast_server_lockfree/broadcast_server_lockfree.cpp:31:5: note: action::action(action_type, websocketpp::connection_hdl)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:31:5: note: candidate expects 2 arguments, 0 provided
broadcast_server_lockfree/broadcast_server_lockfree.cpp:30:8: note: action::action(const action&)
broadcast_server_lockfree/broadcast_server_lockfree.cpp:30:8: note: candidate expects 1 argument, 0 provided
scons: *** [build/release/broadcast_server_lockfree/broadcast_server_lockfree.o] Error 1
scons: building terminated because of errors.
我对 C++ 几乎一无所知,对错误的搜索也没有任何结果(因为我不知道我在读什么)。
这是 boost::lockfree::queue
例如,如果它有帮助。 http://boost-sandbox.sourceforge.net/doc/html/lockfree/examples.html
请告诉我如何更正此问题。
action
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;
};
最佳答案
来自docs :
T 必须有一个复制构造函数、一个平凡的赋值运算符和一个平凡的析构函数。
因此您的 action
类必须如下所示:
class action
{
public:
action(const action& rhs) { ... }
//Implicitly defined destructor for itself and all member variables
//Implicitly defined operator= for itself and all member variables
};
static_assert
我们在提示,因为你的析构函数和 operator=
不是由编译器隐式定义的(或者 action
的至少一个成员变量就是这种情况)。
编辑:我快速查看了存储库 - 我似乎找不到 connection_hdl
, 并且没有 message_ptr
在 template <typename endpoint> class server
.无论哪种方式,websocketpp::connection_hdl hdl
之一或 server::message_ptr msg
不满足以上条件。只是“加入”一个无锁队列而不是使用 std::queue
这可能是一项需要大量更改的重要任务。
关于c++ -/boost/lockfree/queue.hpp: 错误: 静态断言失败: (boost::has_trivial_destructor<T>::value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15468278/
我有以下实体字段: /** * @Assert\Regex( * pattern = "/^d+\.(jpg|png|gif)$/", * htmlPattern = "/^d+\.(j
我有一个显示查询结果的表。 我使用这个检查表包含结果: cy.get("table", {timeout: 60000}).find("tr[data-index]").should("have.le
void (assert)(int e) { assert(e); } 这里是如何工作的? 最佳答案 void (assert)(int e) 相当于 void assert(int) 为什么
大家好,我的第一次测试遇到了一些问题 我正在写这个 fragment ,但我一直遇到这个问题: java.lang.AssertionError at org.junit.Assert.fail(As
从表中,我获取字符串列表,并想检查当 val!= "A"时,表列表中是否存在字符串“x”: for (int i = 0; i list = new ArrayList(); for(int i=0
我想在现有代码中为 VHDL 断言操作添加一个错误计数器。基本上,我的代码如下所示: assert data = good_data report "Bad data" severity er
我有一个无法处理的问题,所以我想也许你可以帮助我。基本上我有一个函数,它接收 char* 作为参数并对其执行一些操作(我已经检查了这些步骤/函数,它们工作得很好)。如果函数中给出的 char* 是“”
我有一些代码用于检查输入日期是否正确。只需检查是否不超过 12 个月,给定月份中的日期是否正确,并且还应该考虑闰年(因此,基本上是正常的日期检查)。唯一不合适的是年份不应低于 2000。如果日期无效,
我有一个关于 Cypress 断言的问题,最近才开始使用这个测试平台,但是当 URL 返回一个随机数时卡住了,如下所示。 /Geocortex/Essentials/REST/sites/SITE?f
我有一个 Python mock对象,我想断言是否设置了该对象的任何属性。 我不相信PropertyMock将适用于我的目的,因为我必须知道是否设置了任何属性,而不是特定属性。 它也不像我可以模拟模拟
考虑这个简单的基类 Foo 有一个函数 foo 调用一个纯虚函数 foo_,用 Doxygen 记录: class Foo { public: /** \brief This functi
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在这段代码中执行 malloc 时遇到问题, /*function starts*/ if(NULL==(partial_results=(bignum_t**)malloc(sizeof
大家好,我想知道如何将整个代码块放入一个断言中? 例如,我有一个数组,我想对数组的每个值进行断言。这是我的代码的样子: for (int value : values) { assert Wi
这不是我的作业——我只是在练习。我似乎无法完全理解这个断言概念。 1) Determine the pre-condition for x that guarantees the post-condi
是否可以在带有时间戳的断言失败时记录信息 例如 int a = 10 assert( a > 100 ); 那么它将失败并像时间戳一样输出 2013-12-02 , 17:00:05 assert f
由于我们公司不使用单元测试,所以我正在自学对自己的代码进行单元测试。我正在使用标准的 .net 测试框架进行一些非常基本的单元测试。 我的一个方法返回一个 IEnumerable我想测试它的输出。所以
我有一个如下所示的对象数组,并且只想针对数组中的某些字段进行断言。 对象数组 - var a = [{"key":"key2","value":"value2","updatedBy":"name1"
我正在尝试编写一个 PSL 断言来检查输入断言的数量是否与输出断言的数量相匹配。 例如: . 在输入上任何时候都可能发生任何事情,输出也可以在任何时候断言。确切时间未知,也不重要。我要验证的是没有信息
我想在Cypress中做一个断言如下: cy.get(a).should('be.visible').or(()=>{ cy.get(b).should('be.visible'); });
我是一名优秀的程序员,十分优秀!