bakaid commented on a change in pull request #677: MINIFICPP-1065 - Fix UUID
generation uniqueness and thread safety
URL: https://github.com/apache/nifi-minifi-cpp/pull/677#discussion_r344243908
##########
File path: libminifi/test/unit/IdTests.cpp
##########
@@ -199,3 +288,77 @@ TEST_CASE("Test Hex Device Segment 18 bits", "[id]") {
REQUIRE(true == LogTestController::getInstance().contains("Using minifi uid
prefix: 9af8"));
LogTestController::getInstance().reset();
}
+
+
+TEST_CASE("Collision", "[collision]") {
+ TestController test_controller;
+
+ LogTestController::getInstance().setDebug<utils::IdGenerator>();
+ std::shared_ptr<minifi::Properties> id_props =
std::make_shared<minifi::Properties>();
+ SECTION("random") {
+ id_props->set("uid.implementation", "random");
+ }
+ SECTION("time") {
+ id_props->set("uid.implementation", "time");
+ }
+ SECTION("uuid_default") {
+ id_props->set("uid.implementation", "uuid_default");
+ }
+
+ std::shared_ptr<utils::IdGenerator> generator =
utils::IdGenerator::getIdGenerator();
+ generator->initialize(id_props);
+
+ std::vector<utils::Identifier> uuids(16 * 1024U);
+ std::vector<std::thread> threads;
+ for (size_t i = 0U; i < 16U; i++) {
+ threads.emplace_back([&, i](){
Review comment:
It does, but I explicitly want to capture it by value to make all threads
have a unique one. I will rewrite this to explicitly capture everything it
needs to make it more readable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services