implement a platform neutral usleep() using C++11
This commit is contained in:
@ -39,7 +39,6 @@
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -692,11 +691,11 @@ int Variable::next(int narg, char **arg)
|
||||
int seed = 12345 + universe->me + which[find(arg[0])];
|
||||
if (!random) random = new RanMars(lmp,seed);
|
||||
int delay = (int) (1000000*random->uniform());
|
||||
usleep(delay);
|
||||
platform::usleep(delay);
|
||||
while (1) {
|
||||
if (!rename("tmp.lammps.variable","tmp.lammps.variable.lock")) break;
|
||||
delay = (int) (1000000*random->uniform());
|
||||
usleep(delay);
|
||||
platform::usleep(delay);
|
||||
}
|
||||
|
||||
// if the file cannot be found, we may have a race with some
|
||||
@ -719,7 +718,7 @@ int Variable::next(int narg, char **arg)
|
||||
break;
|
||||
}
|
||||
delay = (int) (1000000*random->uniform());
|
||||
usleep(delay);
|
||||
platform::usleep(delay);
|
||||
}
|
||||
delete random;
|
||||
random = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user