| 1234567891011121314151617181920212223242526272829 |
- //
- // thread_safe.cpp
- // shared_random_generator
- //
- // Created by Sam Jaffe on 3/19/23.
- // Copyright © 2023 Sam Jaffe. All rights reserved.
- //
- #include "random/thread_safe.h"
- namespace engine::random {
- ThreadSafeDevice::ThreadSafeDevice(std::unique_ptr<Device> impl)
- : impl_(std::move(impl)) {}
- int32_t ThreadSafeDevice::inclusive(int32_t min, int32_t max) {
- std::lock_guard lock(mutex_);
- return impl_->exclusive(min, max);
- }
- uint32_t ThreadSafeDevice::inclusive(uint32_t min, uint32_t max) {
- std::lock_guard lock(mutex_);
- return impl_->exclusive(min, max);
- }
- double ThreadSafeDevice::exclusive(double min, double max) {
- std::lock_guard lock(mutex_);
- return impl_->exclusive(min, max);
- }
- }
|