提交 ba2b6af4 编写于 作者: Y youngwolf

Fix compilation error.

Add new macro ASCS_ARBITRARY_SEND.
上级 1c30c3e4
......@@ -1093,6 +1093,11 @@ static_assert(ASCS_MSG_HANDLING_INTERVAL >= 0, "the interval of msg handling mus
//during message sending, calling send_msg() will fail, this is by design to avoid asio::io_context using up all virtual memory, this also
// means that before the sending really started, you can greedily call send_msg() and may exhaust all virtual memory, please note.
//#define ASCS_ARBITRARY_SEND
//dispatch an async do_send_msg invocation for each message, this feature brings 2 behaviors:
// 1. it can also fix the situation i described for macro ASCS_EXPOSE_SEND_INTERFACE,
// 2. it brings better effeciency for specific ENV, try to find them by you own.
//#define ASCS_PASSIVE_RECV
//to gain the ability of changing the unpacker at runtime, with this macro, ascs will not do message receiving automatically (except
// the first one, if macro ASCS_SYNC_RECV been defined, the first one will be omitted too), so you need to manually call recv_msg(),
......
......@@ -32,7 +32,7 @@ public:
service_pump(concurrency_hint), Service((service_pump&) *this, std::forward<Arg>(arg)) {}
#else
single_service_pump() : Service((service_pump&) *this) {}
template<typename Arg> single_service_pump() : Service((service_pump&) *this, std::forward<Arg>(arg)) {}
template<typename Arg> single_service_pump(Arg&& arg) : Service((service_pump&) *this, std::forward<Arg>(arg)) {}
#endif
};
......
......@@ -154,7 +154,11 @@ public:
#ifndef ASCS_EXPOSE_SEND_INTERFACE
private:
#endif
#ifdef ASCS_ARBITRARY_SEND
void send_msg() {dispatch_strand(rw_strand, [this]() {this->do_send_msg();});}
#else
void send_msg() {if (!sending && is_ready()) dispatch_strand(rw_strand, [this]() {this->do_send_msg();});}
#endif
public:
void start_heartbeat(int interval, int max_absence = ASCS_HEARTBEAT_MAX_ABSENCE)
......
......@@ -382,7 +382,7 @@ private:
#endif
#ifdef ASCS_WANT_ALL_MSG_SEND_NOTIFY
if (send_buffer.empty())
#if defined(ASCS_WANT_ALL_MSG_SEND_NOTIFY) || !defined(ASCS_WANT_BATCH_MSG_SEND_NOTIFY)
#if defined(ASCS_WANT_MSG_SEND_NOTIFY) || !defined(ASCS_WANT_BATCH_MSG_SEND_NOTIFY)
this->on_all_msg_send(sending_msgs.back());
#else
{
......@@ -397,7 +397,9 @@ private:
#endif
#endif
sending_msgs.clear();
#ifndef ASCS_ARBITRARY_SEND
if (!do_send_msg(true) && !send_buffer.empty()) //send msg in sequence
#endif
do_send_msg(true); //just make sure no pending msgs
}
else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册