Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Implement SpanContext::Clone #138

Merged
merged 1 commit into from
Nov 21, 2018
Merged
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
8 changes: 8 additions & 0 deletions src/jaegertracing/SpanContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <iomanip>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -164,6 +165,13 @@ class SpanContext : public opentracing::SpanContext {
forEachBaggageItem(f);
}

std::unique_ptr<opentracing::SpanContext> Clone() const noexcept
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a lock guard here please:

std::lock_guard<std::mutex> lock(_mutex);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

std::lock_guard<std::mutex> lock(_mutex);
return std::unique_ptr<opentracing::SpanContext>(
new SpanContext(*this));
}

friend bool operator==(const SpanContext& lhs, const SpanContext& rhs)
{
{
Expand Down