RandomNumberGenerator.cpp 725 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzQtComponents/Utilities/RandomNumberGenerator.h>
  9. #include <AzCore/std/smart_ptr/unique_ptr.h>
  10. namespace AzQtComponents
  11. {
  12. namespace
  13. {
  14. thread_local AZStd::unique_ptr<QRandomGenerator> generator;
  15. } // anonymous namespace
  16. QRandomGenerator* GetRandomGenerator()
  17. {
  18. if (!generator)
  19. {
  20. generator.reset(new QRandomGenerator(QRandomGenerator::system()->generate()));
  21. }
  22. return generator.get();
  23. }
  24. } // namespace AzQtComponents