Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/asynchronous_echo_c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = FLAGS_protocol;
options.connection_type = FLAGS_connection_type;
Expand All @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {
// Send a request and wait for the response every 1 second.
int log_id = 0;
while (!brpc::IsAskedToQuit()) {
// Since we are sending asynchronous RPC (`done' is not NULL),
// Since we are sending asynchronous RPC (`done' is not nullptr),
// these objects MUST remain valid until `done' is called.
// As a result, we allocate these objects on heap
example::EchoResponse* response = new example::EchoResponse();
Expand Down
4 changes: 2 additions & 2 deletions example/asynchronous_echo_c++/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class EchoServiceImpl : public example::EchoService {
// at this time res is already sent to client, but cntl/req/res is not destructed
std::string req_str;
std::string res_str;
json2pb::ProtoMessageToJson(*req, &req_str, NULL);
json2pb::ProtoMessageToJson(*res, &res_str, NULL);
json2pb::ProtoMessageToJson(*req, &req_str, nullptr);
json2pb::ProtoMessageToJson(*res, &res_str, nullptr);
LOG(INFO) << "req:" << req_str
<< " res:" << res_str;
}
Expand Down
6 changes: 3 additions & 3 deletions example/auto_concurrency_limiter/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void RunCase(test::ControlService_Stub &cntl_stub,
test::NotifyResponse cntl_rsp;
brpc::Controller cntl;
cntl_req.set_message("StartCase");
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL);
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr);
CHECK(!cntl.Failed()) << "control failed";

TestCaseContext context(test_case);
Expand All @@ -208,7 +208,7 @@ void RunCase(test::ControlService_Stub &cntl_stub,
::sleep(FLAGS_case_interval);
cntl.Reset();
cntl_req.set_message("StopCase");
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL);
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr);
CHECK(!cntl.Failed()) << "control failed";
LOG(INFO) << "Case `" << test_case.case_name() << "' finshed:";
}
Expand Down Expand Up @@ -237,7 +237,7 @@ int main(int argc, char* argv[]) {
test::NotifyRequest cntl_req;
test::NotifyResponse cntl_rsp;
cntl_req.set_message("ResetCaseSet");
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, NULL);
cntl_stub.Notify(&cntl, &cntl_req, &cntl_rsp, nullptr);
CHECK(!cntl.Failed()) << "Cntl Failed";
for (int i = 0; i < case_set.test_case_size(); ++i) {
RunCase(cntl_stub, case_set.test_case(i));
Expand Down
4 changes: 2 additions & 2 deletions example/auto_concurrency_limiter/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ControlServiceImpl : public test::ControlService {
brpc::SERVER_OWNS_SERVICE) != 0) {
LOG(FATAL) << "Fail to add service";
}
g_timer_thread.start(NULL);
g_timer_thread.start(nullptr);
}
virtual ~ControlServiceImpl() {
_echo_service->StopTestCase();
Expand Down Expand Up @@ -284,7 +284,7 @@ int main(int argc, char* argv[]) {
return -1;
}

if (server.Start(FLAGS_cntl_port, NULL) != 0) {
if (server.Start(FLAGS_cntl_port, nullptr) != 0) {
LOG(ERROR) << "Fail to start EchoServer";
return -1;
}
Expand Down
6 changes: 3 additions & 3 deletions example/backup_request_c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = FLAGS_protocol;
options.connection_type = FLAGS_connection_type;
Expand All @@ -68,9 +68,9 @@ int main(int argc, char* argv[]) {

request.set_index(++counter);

// Because `done'(last parameter) is NULL, this function waits until
// Because `done'(last parameter) is nullptr, this function waits until
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
stub.Echo(&cntl, &request, &response, nullptr);
if (!cntl.Failed()) {
LOG(INFO) << "Received response[index=" << response.index()
<< "] from " << cntl.remote_side()
Expand Down
6 changes: 3 additions & 3 deletions example/baidu_proxy_and_generic_call/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = brpc::PROTOCOL_BAIDU_STD;
options.connection_type = FLAGS_connection_type;
Expand Down Expand Up @@ -73,9 +73,9 @@ int main(int argc, char* argv[]) {
// being serialized into protobuf messages.
cntl.request_attachment().append(FLAGS_attachment);

// Because `done'(last parameter) is NULL, this function waits until
// Because `done'(last parameter) is nullptr, this function waits until
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
stub.Echo(&cntl, &request, &response, nullptr);
if (!cntl.Failed()) {
LOG(INFO) << "Received response from " << cntl.remote_side()
<< " to " << cntl.local_side()
Expand Down
4 changes: 2 additions & 2 deletions example/baidu_proxy_and_generic_call/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BaiduMasterServiceImpl : public brpc::BaiduMasterService {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = brpc::PROTOCOL_BAIDU_STD;
options.connection_type = FLAGS_connection_type;
Expand Down Expand Up @@ -84,7 +84,7 @@ class BaiduMasterServiceImpl : public brpc::BaiduMasterService {
call_cntl.set_request_compress_type(cntl->request_compress_type());
call_cntl.reset_sampled_request(cntl->release_sampled_request());
// It is ok to use request and response for sync rpc.
channel.CallMethod(NULL, &call_cntl, request, response, NULL);
channel.CallMethod(nullptr, &call_cntl, request, response, nullptr);
(*cntl->response_user_fields())["x-bd-proxy-error-code"] =
butil::IntToString(call_cntl.ErrorCode());
if (call_cntl.Failed()) {
Expand Down
14 changes: 7 additions & 7 deletions example/bthread_tag_echo_c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ static void* sender(void* arg) {
// being serialized into protobuf messages.
cntl.request_attachment().append(g_attachment);

// Because `done'(last parameter) is NULL, this function waits until
// Because `done'(last parameter) is nullptr, this function waits until
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
stub.Echo(&cntl, &request, &response, nullptr);
if (!cntl.Failed()) {
g_latency_recorder << cntl.latency_us();
} else {
Expand All @@ -79,7 +79,7 @@ static void* sender(void* arg) {
bthread_usleep(50000);
}
}
return NULL;
return nullptr;
}

int main(int argc, char* argv[]) {
Expand All @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = FLAGS_protocol;
options.connection_type = FLAGS_connection_type;
Expand Down Expand Up @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
Expand All @@ -144,9 +144,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(pids[i], NULL);
pthread_join(pids[i], nullptr);
} else {
bthread_join(bids[i], NULL);
bthread_join(bids[i], nullptr);
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/cancel_c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) {
// Channel is thread-safe and can be shared by all threads in your program.
brpc::Channel channel;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
brpc::ChannelOptions options;
options.protocol = FLAGS_protocol;
options.connection_type = FLAGS_connection_type;
Expand Down
16 changes: 8 additions & 8 deletions example/cascade_echo_c++/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void* sender(void* arg) {
// being serialized into protobuf messages.
cntl.request_attachment().append(FLAGS_attachment);

// Because `done'(last parameter) is NULL, this function waits until
// Because `done'(last parameter) is nullptr, this function waits until
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
stub.Echo(&cntl, &request, &response, nullptr);
if (cntl.Failed()) {
//LOG_EVERY_SECOND(WARNING) << "Fail to send EchoRequest, " << cntl.ErrorText();
} else {
Expand All @@ -82,7 +82,7 @@ void* sender(void* arg) {
bthread_usleep(FLAGS_sleep_ms * 1000L);
}
}
return NULL;
return nullptr;
}

int main(int argc, char* argv[]) {
Expand All @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) {
options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
options.max_retry = FLAGS_max_retry;

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
// options, see `brpc/channel.h'.
if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
LOG(ERROR) << "Fail to initialize channel";
Expand All @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) {
if (!FLAGS_use_bthread) {
pids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(&pids[i], NULL, sender, &channel) != 0) {
if (pthread_create(&pids[i], nullptr, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create pthread";
return -1;
}
Expand All @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
bids.resize(FLAGS_thread_num);
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (bthread_start_background(
&bids[i], NULL, sender, &channel) != 0) {
&bids[i], nullptr, sender, &channel) != 0) {
LOG(ERROR) << "Fail to create bthread";
return -1;
}
Expand All @@ -140,9 +140,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(pids[i], NULL);
pthread_join(pids[i], nullptr);
} else {
bthread_join(bids[i], NULL);
bthread_join(bids[i], nullptr);
}
}
return 0;
Expand Down
4 changes: 2 additions & 2 deletions example/cascade_echo_c++/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CascadeEchoService : public EchoService {

cntl2.set_timeout_ms(FLAGS_timeout_ms);
cntl2.set_max_retry(FLAGS_max_retry);
stub.Echo(&cntl2, &request2, &response2, NULL);
stub.Echo(&cntl2, &request2, &response2, nullptr);
if (cntl2.Failed()) {
CLOGE(&cntl2) << "Fail to send EchoRequest, " << cntl2.ErrorText();
cntl->SetFailed(cntl2.ErrorCode(), "%s", cntl2.ErrorText().c_str());
Expand Down Expand Up @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) {
coption.protocol = brpc::PROTOCOL_HTTP;
}

// Initialize the channel, NULL means using default options.
// Initialize the channel, nullptr means using default options.
// options, see `brpc/channel.h'.
if (FLAGS_server.empty()) {
if (channel.Init("localhost", FLAGS_port, &coption) != 0) {
Expand Down
2 changes: 1 addition & 1 deletion example/coroutine/coroutine_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class EchoServiceImpl : public EchoService {
brpc::ClosureGuard done_guard(done);
EchoService_Stub stub(&_channel);
brpc::Controller cntl;
stub.Echo(&cntl, request, response, NULL);
stub.Echo(&cntl, request, response, nullptr);
if (cntl.Failed()) {
response->set_message(cntl.ErrorText());
}
Expand Down
16 changes: 8 additions & 8 deletions example/couchbase_c++/multithreaded_couchbase_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void* thread_worker(void* arg) {
if (!auth_result.success) {
std::cout << RED << "Thread " << args->thread_id << ": Auth failed - "
<< auth_result.error_message << RESET << std::endl;
return NULL;
return nullptr;
}

// // Select bucket
Expand All @@ -197,7 +197,7 @@ void* thread_worker(void* arg) {
// std::cout << RED << "Thread " << args->thread_id
// << ": Bucket selection failed - " << bucket_result.error_message
// << RESET << std::endl;
// return NULL;
// return nullptr;
// }

std::cout << GREEN << "Thread " << args->thread_id << " connected to bucket "
Expand Down Expand Up @@ -228,7 +228,7 @@ void* thread_worker(void* arg) {
<< " operations successful, " << failed << " failed" << RESET
<< std::endl;

return NULL;
return nullptr;
}

void* shared_object_thread_worker(void *arg){
Expand All @@ -246,7 +246,7 @@ void* shared_object_thread_worker(void *arg){
// Small delay between operations
bthread_usleep(10000); // 10ms
}
return NULL;
return nullptr;
}

// Print simple statistics
Expand Down Expand Up @@ -319,7 +319,7 @@ int main(int argc, char* argv[]) {

// Start all threads
for (int i = 0; i < NUM_THREADS; ++i) {
if (bthread_start_background(&threads[i], NULL, thread_worker, &args[i]) !=
if (bthread_start_background(&threads[i], nullptr, thread_worker, &args[i]) !=
0) {
std::cout << RED << "Failed to create thread " << i << RESET << std::endl;
return -1;
Expand All @@ -332,7 +332,7 @@ int main(int argc, char* argv[]) {
std::cout << YELLOW << "Waiting for all threads to complete..." << RESET
<< std::endl;
for (int i = 0; i < NUM_THREADS; ++i) {
bthread_join(threads[i], NULL);
bthread_join(threads[i], nullptr);
}

std::cout << GREEN << "All threads completed!" << RESET << std::endl;
Expand All @@ -357,14 +357,14 @@ int main(int argc, char* argv[]) {
}

for(int i = 0; i < NUM_THREADS; ++i){
if (bthread_start_background(&threads[i], NULL, shared_object_thread_worker, &args[i]) !=
if (bthread_start_background(&threads[i], nullptr, shared_object_thread_worker, &args[i]) !=
0) {
std::cout << RED << "Failed to create shared object thread " << i << RESET << std::endl;
return -1;
}
}
for(int i = 0; i < NUM_THREADS; ++i){
bthread_join(threads[i], NULL);
bthread_join(threads[i], nullptr);
}
std::cout << GREEN << "All shared object threads completed!" << RESET << std::endl;

Expand Down
10 changes: 5 additions & 5 deletions example/couchbase_c++/traditional_brpc_couchbase_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main() {
brpc::CouchbaseOperations::CouchbaseResponse res;
uint64_t cas;
req.authenticateRequest("Administrator", "password");
channel.CallMethod(NULL, &cntl, &req, &res, NULL);
channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << "Unable to authenticate: Something went wrong"
<< cntl.ErrorText();
Expand All @@ -63,7 +63,7 @@ int main() {
req.Clear();
res.Clear();
req.selectBucketRequest("testing");
channel.CallMethod(NULL, &cntl, &req, &res, NULL);
channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << "Unable to select bucket: Something went wrong"
<< cntl.ErrorText();
Expand Down Expand Up @@ -92,7 +92,7 @@ int main() {
"sample_key",
R"({"name": "John Doe", "age": 30, "email": "john@example.com"})",
0 /*flags*/, 0 /*exptime*/, 0 /*cas*/);
channel.CallMethod(NULL, &cntl, &req, &res, NULL);
channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << "Unable to add key-value: Something went wrong"
<< cntl.ErrorText();
Expand All @@ -118,7 +118,7 @@ int main() {
req.Clear();
res.Clear();
req.getRequest("sample_key");
channel.CallMethod(NULL, &cntl, &req, &res, NULL);
channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << "Unable to get value for key: Something went wrong"
<< cntl.ErrorText();
Expand Down Expand Up @@ -147,7 +147,7 @@ int main() {
req.Clear();
res.Clear();
req.deleteRequest("sample_key");
channel.CallMethod(NULL, &cntl, &req, &res, NULL);
channel.CallMethod(nullptr, &cntl, &req, &res, nullptr);
if (cntl.Failed()) {
LOG(ERROR) << "Unable to delete key-value: Something went wrong"
<< cntl.ErrorText();
Expand Down
Loading
Loading