Commit 5654319b authored by zhujiashun's avatar zhujiashun

Fix explicit type conversion from bthread_t to pthread_t in mac

parent 57c13239
......@@ -4,7 +4,7 @@ project(asynchronous_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(backup_request_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(cancel_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,12 +4,11 @@ project(cascade_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
include(FindThreads)
include(FindProtobuf)
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
......
......@@ -103,19 +103,21 @@ int main(int argc, char* argv[]) {
return -1;
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -135,9 +137,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
return 0;
......
......@@ -4,7 +4,7 @@ project(dynamic_partition_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -148,19 +148,21 @@ int main(int argc, char* argv[]) {
}
g_request.resize(FLAGS_request_size, 'r');
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -198,9 +200,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_hulu_pbrpc C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_sofa_pbrpc C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(echo_c++_ubrpc_compack C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,14 +4,7 @@ project(http_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
set(CMAKE_PREFIX_PATH ${OUTPUT_PATH})
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -87,19 +87,21 @@ int main(int argc, char* argv[]) {
return -1;
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -120,9 +122,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(memcache_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -158,19 +158,21 @@ int main(int argc, char* argv[]) {
<< " values, never expired";
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -186,9 +188,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
if (options.auth) {
......
......@@ -4,7 +4,7 @@ project(multi_threaded_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -117,19 +117,21 @@ int main(int argc, char* argv[]) {
brpc::StartDummyServerAt(FLAGS_dummy_port);
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -145,9 +147,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(multi_threaded_echo_fns_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -119,19 +119,21 @@ int main(int argc, char* argv[]) {
brpc::StartDummyServerAt(FLAGS_dummy_port);
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -147,9 +149,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(multi_threaded_mcpack_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -113,19 +113,21 @@ int main(int argc, char* argv[]) {
brpc::StartDummyServerAt(FLAGS_dummy_port);
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -141,9 +143,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(nshead_extension_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(nshead_pb_extension_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -4,7 +4,7 @@ project(parallel_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -165,19 +165,21 @@ int main(int argc, char* argv[]) {
brpc::StartDummyServerAt(FLAGS_dummy_port);
}
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -199,9 +201,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(partition_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -150,19 +150,21 @@ int main(int argc, char* argv[]) {
}
g_request.resize(FLAGS_request_size, 'r');
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -200,9 +202,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -12,7 +12,7 @@ project(redis_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -143,21 +143,23 @@ int main(int argc, char* argv[]) {
brpc::StartDummyServerAt(FLAGS_dummy_port);
}
std::vector<bthread_t> tids;
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
bids.resize(FLAGS_thread_num);
pids.resize(FLAGS_thread_num);
std::vector<SenderArgs> args;
tids.resize(FLAGS_thread_num);
args.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
args[i].base_index = i * FLAGS_batch;
args[i].redis_channel = &channel;
if (!FLAGS_use_bthread) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &args[i]) != 0) {
if (pthread_create(&pids[i], NULL, sender, &args[i]) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
} else {
if (bthread_start_background(
&tids[i], NULL, sender, &args[i]) != 0) {
&bids[i], NULL, sender, &args[i]) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -174,9 +176,9 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "redis_client is going to quit";
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_bthread) {
pthread_join((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
return 0;
......
......@@ -4,7 +4,7 @@ project(selective_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -197,19 +197,21 @@ int main(int argc, char* argv[]) {
}
g_request.resize(FLAGS_request_size, 'r');
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -225,9 +227,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(session_data_and_thread_local C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
......@@ -108,19 +108,21 @@ int main(int argc, char* argv[]) {
}
g_request.resize(FLAGS_request_size, 'r');
std::vector<bthread_t> tids;
tids.resize(FLAGS_thread_num);
std::vector<bthread_t> bids;
std::vector<pthread_t> pids;
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create((pthread_t*)&tids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
}
} else {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&tids[i], NULL, sender, &channel) != 0) {
&bids[i], NULL, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
......@@ -136,9 +138,9 @@ 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((pthread_t)tids[i], NULL);
pthread_join(pids[i], NULL);
} else {
bthread_join(tids[i], NULL);
bthread_join(bids[i], NULL);
}
}
......
......@@ -4,7 +4,7 @@ project(streaming_echo_c++ C CXX)
option(EXAMPLE_LINK_SO "Whether examples are linked dynamically" OFF)
execute_process(
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -name \"include\" | xargs dirname | tr -d '\n'"
COMMAND bash -c "find ${CMAKE_SOURCE_DIR}/../.. -type d -regex \".*output/include$\" | xargs dirname | tr -d '\n'"
OUTPUT_VARIABLE OUTPUT_PATH
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment