mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-04-12 16:06:42 +02:00
54 lines
1.6 KiB
Diff
54 lines
1.6 KiB
Diff
Patch-Source: https://git.jami.net/savoirfairelinux/jami-daemon/-/commit/ae51349344ca97f140af566598664159d29dca0f
|
|
--
|
|
From ae51349344ca97f140af566598664159d29dca0f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
|
|
Date: Fri, 8 Dec 2023 13:38:52 -0500
|
|
Subject: [PATCH] manager: add function to derive random engines from the main
|
|
one
|
|
|
|
Seeding a random engine from other ones is a common practice that
|
|
reduce resource consumption.
|
|
|
|
Change-Id: I2e692fc2d5caec456c86134cf7d15f4da5017997
|
|
---
|
|
src/manager.cpp | 10 ++++++++++
|
|
src/manager.h | 2 ++
|
|
2 files changed, 12 insertions(+)
|
|
|
|
diff --git a/src/manager.cpp b/src/manager.cpp
|
|
index 4e5bce6f81..54722f24bc 100644
|
|
--- a/src/manager.cpp
|
|
+++ b/src/manager.cpp
|
|
@@ -2771,6 +2771,16 @@ Manager::setAccountDetails(const std::string& accountID,
|
|
});
|
|
}
|
|
|
|
+std::mt19937_64
|
|
+Manager::getSeededRandomEngine()
|
|
+{
|
|
+ std::array<std::mt19937_64::result_type, std::mt19937_64::state_size> sub_seeds;
|
|
+ for (auto& sub_seed : sub_seeds)
|
|
+ sub_seed = rand_();
|
|
+ std::seed_seq seed(sub_seeds.begin(), sub_seeds.end());
|
|
+ return std::mt19937_64(seed);
|
|
+}
|
|
+
|
|
std::string
|
|
Manager::getNewAccountId()
|
|
{
|
|
diff --git a/src/manager.h b/src/manager.h
|
|
index a0e822d8f1..659697cd0c 100644
|
|
--- a/src/manager.h
|
|
+++ b/src/manager.h
|
|
@@ -442,6 +442,8 @@ public:
|
|
|
|
void setAccountActive(const std::string& accountID, bool active, bool shutdownConnections);
|
|
|
|
+ std::mt19937_64 getSeededRandomEngine();
|
|
+
|
|
/**
|
|
* Return a new random accountid that is not present in the list
|
|
* @return A brand new accountid
|
|
--
|
|
GitLab
|
|
|