-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
@wu-sheng My project include cpp2sky to report tracing data, i find one thread cost cpu 100%,afer debug i think find a bug:
void TracerImpl::run() {
void* got_tag;
bool ok = false;
while (true) {
// TODO(shikugawa): cleanup evloop handler.
if (cds_timer_ != nullptr && cds_timer_->check()) {
cdsRequest();
}
grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
&got_tag, &ok, gpr_time_from_nanos(0, GPR_CLOCK_REALTIME));
here should be GPR_TIMESPAN, so i fix like follow in my local branch :
void* got_tag;
bool ok = false;
while (true) {
// TODO(shikugawa): cleanup evloop handler.
if (cds_timer_ != nullptr && cds_timer_->check()) {
cdsRequest();
}
#if 0
grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
&got_tag, &ok, gpr_time_from_nanos(0, GPR_CLOCK_REALTIME));
#endif
grpc::CompletionQueue::NextStatus status = cq_.AsyncNext(
&got_tag, &ok, gpr_time_from_nanos(100000000, GPR_TIMESPAN));
switch (status) {
case grpc::CompletionQueue::TIMEOUT:
continue;
case grpc::CompletionQueue::SHUTDOWN:
return;
case grpc::CompletionQueue::GOT_EVENT:
break;
}
static_cast<StreamCallbackTag*>(got_tag)->callback(!ok);
}
}
Metadata
Metadata
Assignees
Labels
No labels