thread_safe.h 435 B

123456789101112131415161718192021222324252627
  1. //
  2. // thread_safe.h
  3. // shared_random_generator
  4. //
  5. // Created by Sam Jaffe on 3/19/23.
  6. // Copyright © 2023 Sam Jaffe. All rights reserved.
  7. //
  8. #pragma once
  9. #include <mutex>
  10. #include <random/device.h>
  11. namespace engine::random {
  12. class ThreadSafeDevice : public Device {
  13. private:
  14. std::mutex mutex_;
  15. std::unique_ptr<Device> impl_;
  16. public:
  17. ThreadSafeDevice(std::unique_ptr<Device> impl);
  18. uint32_t operator()() final;
  19. };
  20. }