Changeset 2833 for branches/0.9-stable/yat/random/random.cc
- Timestamp:
- Sep 14, 2012, 9:42:09 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9-stable/yat/random/random.cc
r2804 r2833 24 24 #include "yat/statistics/Histogram.h" 25 25 #include "yat/utility/Exception.h" 26 27 #include <boost/thread/locks.hpp> 26 28 27 29 #include <cassert> … … 93 95 if (!rng) 94 96 throw utility::GSL_error("RNG failed to allocate memory"); 97 boost::unique_lock<boost::mutex> lock(mutex_); 95 98 gsl_rng_set(rng, seed_); 96 99 // bump seed to avoid subsequent gsl_rng to be identical … … 98 101 // rng_ owns rng and takes care of deallocation 99 102 rng_.reset(rng); 100 } 103 } // lock is released here 101 104 102 105 103 106 void RNG::seed(unsigned long s) const 104 107 { 108 boost::unique_lock<boost::mutex> lock(mutex_); 105 109 gsl_rng_set(rng(),s); 106 110 seed_ = s+1; 107 } 111 } // lock is released here 108 112 109 113
Note: See TracChangeset
for help on using the changeset viewer.