Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 00b3777

Browse files
authored
Change lambda into IsBufferFull(). (#58)
This is for compatibility with VS2017, which doesn't support the unary plus trick for lambdas.
1 parent 6d9cd80 commit 00b3777

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

opencensus/trace/internal/span_exporter_impl.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ void SpanExporterImpl::StartExportThread() {
5757
thread_started_ = true;
5858
}
5959

60+
bool SpanExporterImpl::IsBufferFull() const {
61+
span_mu_.AssertHeld();
62+
return spans_.size() >= buffer_size_;
63+
}
64+
6065
void SpanExporterImpl::RunWorkerLoop() {
6166
std::vector<opencensus::trace::exporter::SpanData> span_data_;
6267
std::vector<std::shared_ptr<opencensus::trace::SpanImpl>> spans_copy_;
@@ -67,14 +72,9 @@ void SpanExporterImpl::RunWorkerLoop() {
6772
{
6873
absl::MutexLock l(&span_mu_);
6974
// Wait until batch is full or interval time has been exceeded.
70-
span_mu_.AwaitWithDeadline(absl::Condition(
71-
+[](SpanExporterImpl* ptr) {
72-
ptr->span_mu_.AssertHeld();
73-
return ptr->spans_.size() >=
74-
ptr->buffer_size_;
75-
},
76-
this),
77-
next_forced_export_time);
75+
span_mu_.AwaitWithDeadline(
76+
absl::Condition(this, &SpanExporterImpl::IsBufferFull),
77+
next_forced_export_time);
7878
next_forced_export_time = absl::Now() + interval_;
7979
if (spans_.empty()) {
8080
continue;

opencensus/trace/internal/span_exporter_impl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ class SpanExporterImpl {
6666

6767
void StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(handler_mu_);
6868
void RunWorkerLoop();
69+
6970
// Calls all registered handlers and exports the spans contained in span_data.
7071
void Export(const std::vector<SpanData>& span_data);
72+
7173
void ExportForTesting();
7274

75+
// Returns true if the spans_ buffer has filled up.
76+
bool IsBufferFull() const;
77+
7378
static SpanExporterImpl* span_exporter_;
7479
const uint32_t buffer_size_;
7580
const absl::Duration interval_;

0 commit comments

Comments
 (0)