提交 9d93fcb9 编写于 作者: Y YangLi

Fix compilation error for replaceable_udp_unpacker.

Fix duration statistic.
上级 afbc60e6
......@@ -76,7 +76,9 @@ int main(int argc, const char* argv[])
{
std::string str;
std::cin >> str;
if (QUIT_COMMAND == str)
if (str.empty())
;
else if (QUIT_COMMAND == str)
{
sp.stop_service(&client_);
sp.stop_service();
......
......@@ -6,6 +6,7 @@
//so, define this to avoid hooks for async call (and slightly improve efficiency),
//any value which is bigger than zero is okay.
#define ASCS_SYNC_RECV
#define ASCS_SYNC_SEND
#define ASCS_PASSIVE_RECV //if you annotate this definition, this demo will use mix model to receive messages, which means
//some messages will be dispatched via on_msg_handle(), some messages will be returned via sync_recv_msg(),
//type more than one messages (separate them by space) in one line with ENTER key to send them,
......@@ -13,7 +14,6 @@
//#define ASCS_DEFAULT_UDP_UNPACKER replaceable_udp_unpacker<>
#define ASCS_HEARTBEAT_INTERVAL 5 //neither udp_unpacker nor replaceable_udp_unpacker support heartbeat message,
//so heartbeat will be treated as normal message.
#define ASCS_SYNC_SEND
//configuration
#include <ascs/ext/udp.h>
......
......@@ -208,7 +208,7 @@ protected:
virtual ~i_unpacker() {}
public:
virtual void reset() {};
virtual void reset() {}
//heartbeat must not be included in msg_can, otherwise you must handle heartbeat at where you handle normal messges.
virtual bool parse_msg(size_t bytes_transferred, container_type& msg_can) = 0;
virtual size_t completion_condition(const asio::error_code& ec, size_t bytes_transferred) {return 0;}
......@@ -371,7 +371,7 @@ template<typename T>
struct obj_with_begin_time : public T
{
obj_with_begin_time(bool need_cv = false) {check_and_create_cv(need_cv);}
obj_with_begin_time(T&& obj, bool need_cv = false) : T(std::move(obj)) {check_and_create_cv(need_cv);}
obj_with_begin_time(T&& obj, bool need_cv = false) : T(std::move(obj)) {restart(); check_and_create_cv(need_cv);}
obj_with_begin_time& operator=(T&& obj) {T::operator=(std::move(obj)); restart(); return *this;}
obj_with_begin_time(obj_with_begin_time&& other) : T(std::move(other)), begin_time(std::move(other.begin_time)), cv(std::move(other.cv)) {}
obj_with_begin_time& operator=(obj_with_begin_time&& other) {T::operator=(std::move(other)); begin_time = std::move(other.begin_time); cv = std::move(other.cv); return *this;}
......
......@@ -185,7 +185,7 @@ private:
typedef ascs::i_unpacker<T> super;
public:
virtual typename super::msg_type parse_msg(size_t bytes_transferred, typename super::container_type& msg_can)
virtual bool parse_msg(size_t bytes_transferred, typename super::container_type& msg_can)
{
assert(bytes_transferred <= ASCS_MSG_BUFFER_SIZE);
......
......@@ -185,4 +185,3 @@ private:
} //namespace
#endif /* _ASCS_TIMER_H_ */
......@@ -234,7 +234,8 @@ private:
this->stat.send_time_sum += statistic::now() - last_send_msg.begin_time;
++this->stat.send_msg_sum;
#ifdef ASCS_SYNC_SEND
if (last_send_msg.cv) last_send_msg.cv->notify_one();
if (last_send_msg.cv)
last_send_msg.cv->notify_one();
#endif
#ifdef ASCS_WANT_MSG_SEND_NOTIFY
this->on_msg_send(last_send_msg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册