Ignore:
Timestamp:
Sep 14, 2012, 9:42:09 AM (9 years ago)
Author:
Peter
Message:

fixes #720

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9-stable/yat/random/random.cc

    r2804 r2833  
    2424#include "yat/statistics/Histogram.h"
    2525#include "yat/utility/Exception.h"
     26
     27#include <boost/thread/locks.hpp>
    2628
    2729#include <cassert>
     
    9395    if (!rng)
    9496      throw utility::GSL_error("RNG failed to allocate memory");
     97    boost::unique_lock<boost::mutex> lock(mutex_);
    9598    gsl_rng_set(rng, seed_);
    9699    // bump seed to avoid subsequent gsl_rng to be identical
     
    98101    // rng_ owns rng and takes care of deallocation
    99102    rng_.reset(rng);
    100   }
     103  } // lock is released here
    101104
    102105
    103106  void RNG::seed(unsigned long s) const
    104107  {
     108    boost::unique_lock<boost::mutex> lock(mutex_);
    105109    gsl_rng_set(rng(),s);
    106110    seed_ = s+1;
    107   }
     111  } // lock is released here
    108112
    109113
Note: See TracChangeset for help on using the changeset viewer.