Skip to content
This repository was archived by the owner on Apr 6, 2019. It is now read-only.

Commit e0266b3

Browse files
committed
make READ_SIZE configurable at compile time
1 parent 486bcd9 commit e0266b3

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ set_target_properties(${PROJECT}
6565
PROPERTIES
6666
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/target")
6767

68+
IF (CPP_REDIS_READ_SIZE)
69+
set_target_properties(${PROJECT}
70+
PROPERTIES
71+
COMPILE_DEFINITIONS "CPP_REDIS_READ_SIZE=${CPP_REDIS_READ_SIZE}")
72+
ENDIF (CPP_REDIS_READ_SIZE)
73+
6874

6975
###
7076
# install
7177
###
7278
install (TARGETS ${PROJECT} DESTINATION lib)
7379
install (DIRECTORY ${CPP_REDIS_INCLUDES}/ DESTINATION include)
7480

81+
7582
###
7683
# examples
7784
###

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cmake .. # only library
2121
cmake .. -DBUILD_TESTS=true # library and tests
2222
cmake .. -DBUILD_EXAMPLES=true # library and examples
2323
cmake .. -DBUILD_TESTS=true -DBUILD_EXAMPLES=true # library, tests and examples
24+
cmake .. -DCPP_REDIS_READ_SIZE=4096 # Change the read size used to read data from sockets (default: 4096)
2425
make -j
2526
```
2627

includes/cpp_redis/network/tcp_client.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#include "cpp_redis/network/io_service.hpp"
1111
#include "cpp_redis/redis_error.hpp"
1212

13+
#ifndef CPP_REDIS_READ_SIZE
14+
# define CPP_REDIS_READ_SIZE 4096
15+
#endif /* CPP_REDIS_READ_SIZE */
16+
1317
namespace cpp_redis {
1418

1519
namespace network {
@@ -60,7 +64,7 @@ class tcp_client {
6064
std::atomic_bool m_is_connected;
6165

6266
//! buffers
63-
static const unsigned int READ_SIZE = 2048;
67+
static const unsigned int READ_SIZE = CPP_REDIS_READ_SIZE;
6468
std::vector<char> m_read_buffer;
6569
std::vector<char> m_write_buffer;
6670

0 commit comments

Comments
 (0)