Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
694b0290
Commit
694b0290
authored
Apr 08, 2018
by
zyearn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make examples can be compiled and run
parent
0fe6c3d0
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
473 additions
and
54 deletions
+473
-54
CMakeLists.txt
example/asynchronous_echo_c++/CMakeLists.txt
+26
-2
CMakeLists.txt
example/backup_request_c++/CMakeLists.txt
+26
-2
CMakeLists.txt
example/cancel_c++/CMakeLists.txt
+26
-2
CMakeLists.txt
example/cascade_echo_c++/CMakeLists.txt
+26
-2
client.cpp
example/cascade_echo_c++/client.cpp
+2
-2
CMakeLists.txt
example/dynamic_partition_echo_c++/CMakeLists.txt
+29
-2
client.cpp
example/dynamic_partition_echo_c++/client.cpp
+3
-3
CMakeLists.txt
example/echo_c++_hulu_pbrpc/CMakeLists.txt
+26
-2
CMakeLists.txt
example/echo_c++_sofa_pbrpc/CMakeLists.txt
+26
-2
CMakeLists.txt
example/echo_c++_ubrpc_compack/CMakeLists.txt
+26
-2
CMakeLists.txt
example/http_c++/CMakeLists.txt
+31
-2
benchmark_http.cpp
example/http_c++/benchmark_http.cpp
+2
-2
CMakeLists.txt
example/memcache_c++/CMakeLists.txt
+26
-2
client.cpp
example/memcache_c++/client.cpp
+2
-2
CMakeLists.txt
example/multi_threaded_echo_c++/CMakeLists.txt
+26
-2
client.cpp
example/multi_threaded_echo_c++/client.cpp
+2
-2
CMakeLists.txt
example/multi_threaded_echo_fns_c++/CMakeLists.txt
+26
-2
client.cpp
example/multi_threaded_echo_fns_c++/client.cpp
+2
-2
CMakeLists.txt
example/multi_threaded_mcpack_c++/CMakeLists.txt
+26
-2
client.cpp
example/multi_threaded_mcpack_c++/client.cpp
+2
-2
CMakeLists.txt
example/nshead_extension_c++/CMakeLists.txt
+26
-2
CMakeLists.txt
example/nshead_pb_extension_c++/CMakeLists.txt
+26
-2
CMakeLists.txt
example/parallel_echo_c++/CMakeLists.txt
+26
-2
client.cpp
example/parallel_echo_c++/client.cpp
+2
-2
CMakeLists.txt
example/partition_echo_c++/CMakeLists.txt
+29
-2
client.cpp
example/partition_echo_c++/client.cpp
+3
-3
No files found.
example/asynchronous_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
asynchronous_echo_client client.cpp
${
PROTO_SRC
}
)
add_executable
(
asynchronous_echo_server server.cpp
${
PROTO_SRC
}
)
...
...
example/backup_request_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
backup_request_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
backup_request_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/cancel_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
cancel_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
cancel_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/cascade_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
cascade_echo_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
cascade_echo_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/cascade_echo_c++/client.cpp
View file @
694b0290
...
...
@@ -107,7 +107,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -135,7 +135,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/dynamic_partition_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,18 +71,45 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
dynamic_partition_echo_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
dynamic_partition_echo_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
target_link_libraries
(
dynamic_partition_echo_client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
target_link_libraries
(
dynamic_partition_echo_server
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
file
(
COPY
${
CMAKE_SOURCE_DIR
}
/server_list
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
example/dynamic_partition_echo_c++/client.cpp
View file @
694b0290
...
...
@@ -152,7 +152,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -188,7 +188,7 @@ int main(int argc, char* argv[]) {
pthread_mutex_unlock
(
&
g_latency_mutex
);
const
int64_t
avg_latency
=
(
latency_sum
-
last_latency_sum
)
/
std
::
max
(
nsuccess
-
last_counter
,
1L
);
std
::
max
(
nsuccess
-
last_counter
,
1L
L
);
LOG
(
INFO
)
<<
"Sending EchoRequest at qps="
<<
nsuccess
-
last_counter
<<
" latency="
<<
avg_latency
;
last_counter
=
nsuccess
;
...
...
@@ -198,7 +198,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/echo_c++_hulu_pbrpc/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
echo_hulu_pbrpc_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
echo_hulu_pbrpc_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/echo_c++_sofa_pbrpc/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
echo_sofa_pbrpc_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
echo_sofa_pbrpc_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/echo_c++_ubrpc_compack/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
execute_process
(
COMMAND
${
PROTOBUF_PROTOC_EXECUTABLE
}
${
PROTO_FLAGS
}
--cpp_out=
${
CMAKE_CURRENT_BINARY_DIR
}
--proto_path=
${
PROTOBUF_INCLUDE_DIR
}
--proto_path=
${
CMAKE_SOURCE_DIR
}
--plugin=protoc-gen-mcpack=
${
OUTPUT_PATH
}
/bin/protoc-gen-mcpack --mcpack_out=
${
CMAKE_CURRENT_BINARY_DIR
}
${
CMAKE_SOURCE_DIR
}
/echo.proto
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
...
...
example/http_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -78,16 +78,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
http_client http_client.cpp
)
add_executable
(
http_server http_server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
benchmark_http benchmark_http.cpp
)
...
...
@@ -95,3 +119,8 @@ add_executable(benchmark_http benchmark_http.cpp)
target_link_libraries
(
http_server
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
target_link_libraries
(
http_client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
target_link_libraries
(
benchmark_http
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
file
(
COPY
${
CMAKE_SOURCE_DIR
}
/key.pem
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
file
(
COPY
${
CMAKE_SOURCE_DIR
}
/cert.pem
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
example/http_c++/benchmark_http.cpp
View file @
694b0290
...
...
@@ -91,7 +91,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"benchmark_http is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/memcache_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
memcache_client client.cpp
)
target_link_libraries
(
memcache_client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
)
example/memcache_c++/client.cpp
View file @
694b0290
...
...
@@ -162,7 +162,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -186,7 +186,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"memcache_client is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/multi_threaded_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
multi_threaded_echo_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
multi_threaded_echo_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/multi_threaded_echo_c++/client.cpp
View file @
694b0290
...
...
@@ -121,7 +121,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -145,7 +145,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/multi_threaded_echo_fns_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
multi_threaded_echo_fns_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
multi_threaded_echo_fns_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/multi_threaded_echo_fns_c++/client.cpp
View file @
694b0290
...
...
@@ -123,7 +123,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -147,7 +147,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/multi_threaded_mcpack_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
execute_process
(
COMMAND
${
PROTOBUF_PROTOC_EXECUTABLE
}
${
PROTO_FLAGS
}
--cpp_out=
${
CMAKE_CURRENT_BINARY_DIR
}
--proto_path=
${
PROTOBUF_INCLUDE_DIR
}
--proto_path=
${
CMAKE_SOURCE_DIR
}
--plugin=protoc-gen-mcpack=
${
OUTPUT_PATH
}
/bin/protoc-gen-mcpack --mcpack_out=
${
CMAKE_CURRENT_BINARY_DIR
}
${
CMAKE_SOURCE_DIR
}
/echo.proto
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
...
...
example/multi_threaded_mcpack_c++/client.cpp
View file @
694b0290
...
...
@@ -117,7 +117,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -141,7 +141,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/nshead_extension_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
nshead_extension_client client.cpp
)
add_executable
(
nshead_extension_server server.cpp
)
...
...
example/nshead_pb_extension_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -66,16 +66,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
nshead_pb_extension_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
nshead_pb_extension_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/parallel_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,16 +71,40 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
parallel_echo_client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
parallel_echo_server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
...
...
example/parallel_echo_c++/client.cpp
View file @
694b0290
...
...
@@ -169,7 +169,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -199,7 +199,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
example/partition_echo_c++/CMakeLists.txt
View file @
694b0290
...
...
@@ -71,18 +71,45 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
endif
()
include_directories
(
${
LEVELDB_INCLUDE_PATH
}
)
find_library
(
SSL_LIB NAMES ssl
)
if
(
NOT SSL_LIB
)
message
(
FATAL_ERROR
"Fail to find ssl"
)
endif
()
find_library
(
CRYPTO_LIB NAMES crypto
)
if
(
NOT CRYPTO_LIB
)
message
(
FATAL_ERROR
"Fail to find crypto"
)
endif
()
set
(
DYNAMIC_LIB
${
CMAKE_THREAD_LIBS_INIT
}
${
GFLAGS_LIBRARY
}
${
PROTOBUF_LIBRARIES
}
${
LEVELDB_LIB
}
ssl
crypto
${
SSL_LIB
}
${
CRYPTO_LIB
}
dl
)
if
(
CMAKE_SYSTEM_NAME STREQUAL
"Darwin"
)
set
(
DYNAMIC_LIB
${
DYNAMIC_LIB
}
pthread
"-framework CoreFoundation"
"-framework CoreGraphics"
"-framework CoreData"
"-framework CoreText"
"-framework Security"
"-framework Foundation"
"-Wl,-U,_MallocExtension_ReleaseFreeMemory"
"-Wl,-U,_ProfilerStart"
"-Wl,-U,_ProfilerStop"
)
endif
()
add_executable
(
client client.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
add_executable
(
server server.cpp
${
PROTO_SRC
}
${
PROTO_HEADER
}
)
target_link_libraries
(
client
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
target_link_libraries
(
server
${
BRPC_LIB
}
${
DYNAMIC_LIB
}
${
GPERFTOOLS_LIBRARIES
}
)
file
(
COPY
${
CMAKE_SOURCE_DIR
}
/server_list
DESTINATION
${
CMAKE_CURRENT_BINARY_DIR
}
)
example/partition_echo_c++/client.cpp
View file @
694b0290
...
...
@@ -154,7 +154,7 @@ int main(int argc, char* argv[]) {
tids
.
resize
(
FLAGS_thread_num
);
if
(
!
FLAGS_use_bthread
)
{
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
pthread_create
(
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
if
(
pthread_create
(
(
pthread_t
*
)
&
tids
[
i
],
NULL
,
sender
,
&
channel
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to create pthread"
;
return
-
1
;
}
...
...
@@ -190,7 +190,7 @@ int main(int argc, char* argv[]) {
pthread_mutex_unlock
(
&
g_latency_mutex
);
const
int64_t
avg_latency
=
(
latency_sum
-
last_latency_sum
)
/
std
::
max
(
nsuccess
-
last_counter
,
1L
);
std
::
max
(
nsuccess
-
last_counter
,
1L
L
);
LOG
(
INFO
)
<<
"Sending EchoRequest at qps="
<<
nsuccess
-
last_counter
<<
" latency="
<<
avg_latency
;
last_counter
=
nsuccess
;
...
...
@@ -200,7 +200,7 @@ int main(int argc, char* argv[]) {
LOG
(
INFO
)
<<
"EchoClient is going to quit"
;
for
(
int
i
=
0
;
i
<
FLAGS_thread_num
;
++
i
)
{
if
(
!
FLAGS_use_bthread
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
(
pthread_t
)
tids
[
i
],
NULL
);
}
else
{
bthread_join
(
tids
[
i
],
NULL
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment