提交 9cc3d28c 编写于 作者: Y youngwolf

Rename replaceable_unpacker to unpacker2, replaceable_udp_unpacker to...

Rename replaceable_unpacker to unpacker2, replaceable_udp_unpacker to udp_unpacker2, replaceable_packer to packer2,
 because their names confuse users, any packer or unpacker is replaceable for those packer or unpacker that has the same msg_type.
上级 7e54a267
......@@ -21,17 +21,17 @@
//use the following macro to control the type of packer and unpacker
#define PACKER_UNPACKER_TYPE 0
//0-default packer and unpacker, head(length) + body
//1-replaceable packer and unpacker, head(length) + body
//1-packer2 and unpacker2, head(length) + body
//2-fixed length packer and unpacker
//3-prefix and/or suffix packer and unpacker
#if 1 == PACKER_UNPACKER_TYPE
#if defined(_MSC_VER) && _MSC_VER <= 1800
#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
#else
#define ASCS_DEFAULT_PACKER replaceable_packer<>
#define ASCS_DEFAULT_PACKER packer2<>
#endif
#define ASCS_DEFAULT_UNPACKER replaceable_unpacker<>
#define ASCS_DEFAULT_UNPACKER unpacker2<>
#elif 2 == PACKER_UNPACKER_TYPE
#undef ASCS_HEARTBEAT_INTERVAL
#define ASCS_HEARTBEAT_INTERVAL 0 //not support heartbeat
......
......@@ -22,17 +22,17 @@
//use the following macro to control the type of packer and unpacker
#define PACKER_UNPACKER_TYPE 0
//0-default packer and unpacker, head(length) + body
//1-replaceable packer and unpacker, head(length) + body
//1-packer2 and unpacker2, head(length) + body
//2-fixed length packer and unpacker
//3-prefix and/or suffix packer and unpacker
#if 1 == PACKER_UNPACKER_TYPE
#if defined(_MSC_VER) && _MSC_VER <= 1800
#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
#else
#define ASCS_DEFAULT_PACKER replaceable_packer<>
#define ASCS_DEFAULT_PACKER packer2<>
#endif
#define ASCS_DEFAULT_UNPACKER replaceable_unpacker<>
#define ASCS_DEFAULT_UNPACKER unpacker2<>
#elif 2 == PACKER_UNPACKER_TYPE
#undef ASCS_HEARTBEAT_INTERVAL
#define ASCS_HEARTBEAT_INTERVAL 0 //not support heartbeat
......
......@@ -7,7 +7,7 @@
#define ASCS_PASSIVE_RECV
//#define ASCS_INPUT_QUEUE non_lock_queue
//we cannot use non_lock_queue, because we also send messages (talking messages) out of ascs::socket::on_msg_send().
#define ASCS_DEFAULT_UNPACKER replaceable_unpacker<>
#define ASCS_DEFAULT_UNPACKER unpacker2<>
#define ASCS_RECV_BUFFER_TYPE std::vector<asio::mutable_buffer> //scatter-gather buffer, it's very useful under certain situations (for example, ring buffer).
#define ASCS_SCATTERED_RECV_BUFFER //used by unpackers, not belongs to ascs
//configuration
......
......@@ -9,7 +9,7 @@ using namespace ascs::tcp;
extern std::atomic_int_fast64_t received_size;
class data_unpacker : public i_unpacker<replaceable_buffer>
class data_unpacker : public i_unpacker<auto_buffer<i_buffer>>
{
public:
data_unpacker(FILE* file, fl_type data_len) : _file(file), _data_len(data_len)
......
......@@ -12,9 +12,9 @@
//sent to file_client, so sending buffer will always be empty, which means we will never operate sending buffer concurrently,
//so need no locks.
#if defined(_MSC_VER) && _MSC_VER <= 1800
#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
#else
#define ASCS_DEFAULT_PACKER replaceable_packer<>
#define ASCS_DEFAULT_PACKER packer2<>
#endif
#define ASCS_RECV_BUFFER_TYPE std::vector<asio::mutable_buffer> //scatter-gather buffer, it's very useful under certain situations (for example, ring buffer).
#define ASCS_SCATTERED_RECV_BUFFER //used by unpackers, not belongs to ascs
......
......@@ -10,9 +10,9 @@
//sent to file_client, so sending buffer will always be empty, which means we will never operate sending buffer concurrently,
//so need no locks.
#if defined(_MSC_VER) && _MSC_VER <= 1800
#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
#else
#define ASCS_DEFAULT_PACKER replaceable_packer<>
#define ASCS_DEFAULT_PACKER packer2<>
#endif
#define ASCS_RECV_BUFFER_TYPE std::vector<asio::mutable_buffer> //scatter-gather buffer, it's very useful under certain situations (for example, ring buffer).
#define ASCS_SCATTERED_RECV_BUFFER //used by unpackers, not belongs to ascs
......
......@@ -15,7 +15,7 @@ public:
protected:
//msg handling
#if 1 == PACKER_UNPACKER_TYPE
//replaceable_unpacker uses auto_buffer or shared_buffer as its message type
//unpacker2 uses auto_buffer or shared_buffer as its message type
virtual bool on_msg_handle(out_msg_type& msg)
{
auto raw_msg = new string_buffer();
......
......@@ -12,17 +12,17 @@
//use the following macro to control the type of packer and unpacker
#define PACKER_UNPACKER_TYPE 0
//0-default packer and unpacker, head(length) + body
//1-replaceable packer and unpacker, head(length) + body
//1-packer2 and unpacker2, head(length) + body
//2-fixed length packer and unpacker
//3-prefix and/or suffix packer and unpacker
#if 1 == PACKER_UNPACKER_TYPE
#if defined(_MSC_VER) && _MSC_VER <= 1800
#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
#else
#define ASCS_DEFAULT_PACKER replaceable_packer<>
#define ASCS_DEFAULT_PACKER packer2<>
#endif
#define ASCS_DEFAULT_UNPACKER replaceable_unpacker<>
#define ASCS_DEFAULT_UNPACKER unpacker2<>
#elif 2 == PACKER_UNPACKER_TYPE
#undef ASCS_HEARTBEAT_INTERVAL
#define ASCS_HEARTBEAT_INTERVAL 0 //not support heartbeat
......
......@@ -7,11 +7,11 @@
#define ASCS_REUSE_SSL_STREAM
#define ASCS_ENHANCED_STABILITY
//#if defined(_MSC_VER) && _MSC_VER <= 1800
//#define ASCS_DEFAULT_PACKER replaceable_packer<shared_buffer<i_buffer>>
//#define ASCS_DEFAULT_PACKER packer2<shared_buffer<i_buffer>>
//#else
//#define ASCS_DEFAULT_PACKER replaceable_packer<>
//#define ASCS_DEFAULT_PACKER packer2<>
//#endif
//#define ASCS_DEFAULT_UNPACKER replaceable_unpacker<>
//#define ASCS_DEFAULT_UNPACKER unpacker2<>
#define ASCS_HEARTBEAT_INTERVAL 5 //SSL has supported heartbeat because we used user data instead of OOB to implement
//heartbeat since 1.2.0
//configuration
......
......@@ -11,9 +11,8 @@
//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,
//you will see them cross together on the receiver's screen.
//#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_DEFAULT_UDP_UNPACKER udp_unpacker2<>
#define ASCS_HEARTBEAT_INTERVAL 5 //neither udp_unpacker nor udp_unpacker2 support heartbeat message, so heartbeat will be treated as normal message.
//configuration
#include <ascs/ext/udp.h>
......
......@@ -125,10 +125,10 @@ public:
protected:
buffer_type buffer;
};
typedef auto_buffer<i_buffer> replaceable_buffer;
//convert '->' operation to '.' operation
//user need to allocate object, and shared_buffer will free it
//not like auto_buffer, shared_buffer is copyable (seemingly), but auto_buffer is a bit more efficient.
template<typename T> class shared_buffer
{
public:
......@@ -158,8 +158,6 @@ public:
protected:
buffer_type buffer;
};
//not like auto_buffer, shared_buffer is copyable, but auto_buffer is a bit more efficient.
//packer or/and unpacker who used auto_buffer or shared_buffer as its msg type will be replaceable.
//ascs requires that container must take one and only one template argument
#if defined(_MSC_VER) || defined(__clang__) || _GLIBCXX_USE_CXX11_ABI
......
......@@ -56,7 +56,6 @@
* In contrast to non_lock_queue, split message_queue into lock_queue and lock_free_queue.
* Move container related classes and functions from base.h to container.h.
* Improve efficiency in scenarios of low throughput like pingpong test.
* Replaceable packer/unpacker now support replaceable_buffer (an alias of auto_buffer) and shared_buffer to be their message type.
* Move class statistic and obj_with_begin_time out of ascs::socket to reduce template tiers.
*
* 2016.11.1 version 1.1.2
......@@ -480,6 +479,8 @@
* statistic.send_msg_sum may be bigger than before (but statistic.send_byte_sum will be the same), see ENHANCEMENTS section for more details.
* Not support gcc 4.6 any more, please use st_asio_wrapper instead.
* Make function tcp::socket_base::reset to be virtual.
* Rename replaceable_unpacker to unpacker2, replaceable_udp_unpacker to udp_unpacker2, replaceable_packer to packer2, because their names confuse
* users, any packer or unpacker is replaceable for those packer or unpacker that has the same msg_type.
*
* HIGHLIGHT:
* Make client_socket_base be able to call multi_client_base (via i_matrix) like server_socket_base call server_base (via i_server),
......@@ -503,6 +504,9 @@
* direct_send_msg and direct_sync_send_msg support batch operation.
* Introduce virtual function type_name() and type_id() to ascs::socket, they can identify whether a given two ascs::socket has the same type.
* force_shutdown and graceful_shutdown support reconnecting even if the link has broken.
* Extract function start_listen from current implementations.
* Support concurrency hint for io_context if possible.
* Demonstrate how to accept just one client at server endpoint in demo echo_server.
*
* DELETION:
*
......
......@@ -42,7 +42,7 @@ static_assert(ASCS_MSG_BUFFER_SIZE > 0, "message buffer size must be bigger than
namespace ascs { namespace ext {
//implement i_buffer interface, then string_buffer can be wrapped by replaceable_buffer
//implement i_buffer interface, then string_buffer can be wrapped by auto_buffer or shared_buffer
class string_buffer : public std::string, public i_buffer
{
public:
......
......@@ -138,9 +138,9 @@ public:
};
//protocol: length + body
//T can be replaceable_buffer (an alias of auto_buffer) or shared_buffer, the latter makes output messages seemingly copyable.
template<typename T = replaceable_buffer>
class replaceable_packer : public i_packer<T>
//T can be auto_buffer or shared_buffer, the latter makes output messages seemingly copyable.
template<typename T = auto_buffer<i_buffer>>
class packer2 : public i_packer<T>
{
private:
typedef i_packer<T> super;
......
......@@ -146,9 +146,9 @@ protected:
};
//protocol: length + body
//T can be replaceable_buffer (an alias of auto_buffer) or shared_buffer, the latter makes output messages seemingly copyable,
template<typename T = replaceable_buffer>
class replaceable_unpacker : public ascs::i_unpacker<T>
//T can be auto_buffer or shared_buffer, the latter makes output messages seemingly copyable.
template<typename T = auto_buffer<i_buffer>>
class unpacker2 : public ascs::i_unpacker<T>
{
private:
typedef ascs::i_unpacker<T> super;
......@@ -177,9 +177,9 @@ protected:
};
//protocol: UDP has message boundary, so we don't need a specific protocol to unpack it.
//T can be replaceable_buffer (an alias of auto_buffer) or shared_buffer, the latter makes output messages seemingly copyable.
template<typename T = replaceable_buffer>
class replaceable_udp_unpacker : public ascs::i_unpacker<T>
//T can be auto_buffer or shared_buffer, the latter makes output messages seemingly copyable.
template<typename T = auto_buffer<i_buffer>>
class udp_unpacker2 : public ascs::i_unpacker<T>
{
private:
typedef ascs::i_unpacker<T> super;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册