Skip to content

Conversation

@greghuels
Copy link
Collaborator

@greghuels greghuels commented Nov 21, 2025

Eppo Internal:

🎟️ Fixes FFESUPPORT-331

Motivation and Context

We do not want to assume mutex-based synchronization so that we can let customers handle concurrency in whatever way their project requires.

Feedback from customer:

this particular method of implementing thread-safety does not align to what we have in our project. It would be cleaner for us if the code assumed being called from a single thread, and have the caller handle concurrency in whatever way their project requires, rather than assuming mutex-based synchronization and shared ownership.

Description

Update code so that it runs as a single-threaded, letting customers handle concurrency.

  • ✅ Removed std::mutex member variable
  • ✅ Removed #include
  • ✅ Changed from std::shared_ptr to std::optional for internal storage
  • ✅ Updated documentation to clearly state the class is not thread-safe and that callers are responsible for synchronization if needed
  • ✅ Simplified implementation - no more locking, direct member access

How has this been documented?

README.md has been updated to reflect these changes

How has this been tested?

Tests updated and run, including example applications

@greghuels greghuels force-pushed the greg.huels/FFESUPPORT-331/mutex branch from dbe539b to 93076cb Compare November 21, 2025 15:15
@greghuels greghuels changed the title bug: remove opinionated thread-safety feat: allow sdk consumers to choose their synchronization strategy Nov 21, 2025
@greghuels greghuels marked this pull request as ready for review November 21, 2025 15:28
Copy link
Contributor

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

Looks good small actual change then tons of changes from dereferencing to direct access 😛

auto applicationLogger = std::make_shared<MyApplicationLogger>();

auto client = std::make_shared<eppoclient::EppoClient>(
eppoclient::EppoClient client(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok this is why we change from dereferencing to access in the README 👍

Comment on lines +640 to +642
## Thread Safety and Concurrency

The Eppo C++ SDK is **not thread-safe by design**. If you need to use the SDK from multiple threads, you are responsible for providing appropriate synchronization mechanisms in your application.
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

bool feature2 = client.getBoolAssignment("flag2", "user-123", attrs, false);
```
### Multi-Threaded Usage (Synchronization Required)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice thinking including this


Configuration ConfigurationStore::getConfiguration() const {
// Lock and get a copy of the shared_ptr
std::lock_guard<std::mutex> lock(configMutex_);
Copy link
Contributor

Choose a reason for hiding this comment

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

🪓

Comment on lines 28 to 29
// Thread safety test removed - ConfigurationStore is no longer thread-safe by design.
// If thread-safety is required, the caller is responsible for providing synchronization.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is covered in the README unsure if you need this in the test file

@greghuels greghuels merged commit ff7afd8 into main Nov 25, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants